File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "array element" Watch "array element" New topic
Author

array element

Shiva Mohan
Ranch Hand

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

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.
 
jQuery in Action, 2nd edition
 
subject: array element