File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes array element Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "array element" Watch "array element" New topic

array element

Shiva Mohan
Ranch Hand

Joined: Jan 05, 2006
Posts: 481
static char ch;//implicitly \u0000 default value is assigned for ch
int[] ia = new int[1];
ia[ch]=5;//line 3

at line 3,i am thinking like ia[\u0000] is executed.\u0000 is emptyspace.
then how come ia[0] is printed.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Here's your mistake: "\u0000 is emptyspace"

ch is 16 zero bits, and that is 0. The 16 bits are widened to 32 bits but that still results in the array index being 0.

Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
I agree. Here's the link:
subject: array element
It's not a secret anymore!