Page 1 of 1

About Question com.enthuware.ets.scjp.v6.2.268 : enthuware.ocpjp.v17.2.3238 :

Posted: Wed Aug 13, 2014 5:48 pm
by ssack2014
ch is never initialized. How can 'x = ( ba[ch] = b );' compile? does an uninitialized character default to '0'?

Re: About Question com.enthuware.ets.scjp.v6.2.268 :

Posted: Wed Aug 13, 2014 7:14 pm
by admin
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.

Re: About Question com.enthuware.ets.scjp.v6.2.268 :

Posted: Wed Apr 05, 2023 5:11 am
by soncrash
I thought it will not compile, because default value for character primitive is \u0000, so we would have something like that ba[\u0000]

Re: About Question com.enthuware.ets.scjp.v6.2.268 : enthuware.ocpjp.v17.2.3238 :

Posted: Wed Apr 05, 2023 5:49 am
by admin
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'.