In Bill Brogdon's book, Exam Cram 2nd Edition, P50: <code> 1. int counts; 2. int counts; 3. boolean flags [ ]; 4. String names; 5. MyClass things; 6. System.out.println("counts = " + counts); If lines 1 through 6 were in a method and the method was exected, line 6 would print "counts = null" bexause the array object has not yet been constructed. </code> In my mind, any declaration in a method will not be initialized except array elements, but this array object is not still initialized. So I tried to compile it using JDK 1.3, it complained that counts not initialized. Does JDK 1.2 not complain? Jason
Hi Jason, Are you sure you copied the example exactly? You'd get an error if you put lines 1 thru 6 into a method; 'counts' is being declared twice. If you remove line 1, then you're right, you get the 'uninitialized' error. Array reference variables are not automatically initialized to 'null' in methods. ------------------ Jane Griscti Sun Certified Programmer for the Java� 2 Platform
Except for the comment after some lines of codes which i didn't copy and typo like: "bexause", others are from the book. b'cos i only have jdk1.3, i am not sure if it can run by jdk1.2. Right now i got it. Thank you, Jane.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com