Wednesday, May 18, 2011

Arrays and exceptions in java

Some common array programming mistakes are:
Runtime error: Forgetting that array subscripts start with zero. OR Going out of bound
Compile-time error: Writing a.length() instead of a.length. The length() method is used with Strings, not arrays.
Compile-time error: Declaring an array with a size. Eg, int[100] a; instead of int[] a = new int[100];.

No comments:

Post a Comment