I need to change the java API to make say assassinscreed.out.println to work the same way as system.out.println..
Can u pls shed some light on it..?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Simple.
In the class
assassinscreed, add the following declaration:Implementing the equivalent of the
System.setOut()method is tricky. You could use reflection to update the value of theout“constant”. However, there’s a risk that some code will see stale copies of the reference. And I don’t think the JLS provides a way to mitigate that … because from the JLS perspective the value is not supposed to change.So if you need to change the value of
outon the fly, this is not the right solution. In fact, I’d say that it is not the right solution at all. It would be better to write this as:… with a setter if you need one.
(In my opinion, the classic design was a big mistake. It certainly made it a lot harder to implement light-weight applications within a JVM.)
(And don’t ever use “assassinscreed” as a class name. Stick to the standard Java class naming conventions!)