About Question com.enthuware.ets.scjp.v6.2.268 : enthuware.ocpjp.v17.2.3238 :
Moderator: admin
-
- Posts: 3
- Joined: Wed Aug 13, 2014 5:35 pm
- Contact:
About Question com.enthuware.ets.scjp.v6.2.268 : enthuware.ocpjp.v17.2.3238 :
ch is never initialized. How can 'x = ( ba[ch] = b );' compile? does an uninitialized character default to '0'?
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.268 :
static and instance variables are always initialized to their default values if you don't initialize them explicitly.
Local variables aka automatic variables (i.e. variables declared in a method) must be initialized explicitly before using them.
Local variables aka automatic variables (i.e. variables declared in a method) must be initialized explicitly before using them.
If you like our products and services, please help us by posting your review here.
-
- Posts: 8
- Joined: Sat Aug 27, 2016 2:51 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.268 :
I thought it will not compile, because default value for character primitive is \u0000, so we would have something like that ba[\u0000]
-
- Site Admin
- Posts: 10058
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question com.enthuware.ets.scjp.v6.2.268 : enthuware.ocpjp.v17.2.3238 :
Every character is actually just an integer value. So, \u0000 is just an integer value 0. So b[ch] is b[0] if ch is '\u0000'.
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 111 guests