Page 1 of 1

About Question enthuware.ocpjp.ii.v11.2.3345 :

Posted: Mon Feb 01, 2021 3:37 pm
by V_a_l_z
>>>in is a final variable. So, it cannot be reassigned.

It is not entirely true. There is special method System.setIn(InputStream in) for this purpose.

Re: About Question enthuware.ocpjp.ii.v11.2.3345 :

Posted: Mon Feb 01, 2021 10:01 pm
by admin
You are right. The problem statement has been updated to:
"The System.in variable cannot be reassigned to any other stream directly."
and the explanation has also been enhanced to include the setIn method.
thank you for your feedback!

Re: About Question enthuware.ocpjp.ii.v11.2.3345 :

Posted: Fri Jul 29, 2022 3:09 am
by marcoolivi
How can a final variable be changed by a method? Does this have to do with the fact that the method setIn0() is labeled "native"?

Re: About Question enthuware.ocpjp.ii.v11.2.3345 :

Posted: Fri Jul 29, 2022 5:25 am
by admin
That's right. A native method executes low level code directly using OS service calls, bypassing the JVM. This allows it do stuff such as manipulating memory directly.