>>>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.
About Question enthuware.ocpjp.ii.v11.2.3345 :
Moderator: admin
-
- Posts: 1
- Joined: Mon Feb 01, 2021 3:30 pm
- Contact:
-
- Site Admin
- Posts: 10040
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.ii.v11.2.3345 :
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!
"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!
If you like our products and services, please help us by posting your review here.
-
- Posts: 4
- Joined: Wed Jul 27, 2022 7:35 am
- Contact:
Re: About Question enthuware.ocpjp.ii.v11.2.3345 :
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"?
-
- Site Admin
- Posts: 10040
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocpjp.ii.v11.2.3345 :
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.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 23 guests