The main difference is that in the A) first case its Array Type for example int[]
, Object[]
, double[]
, ect.. that has a public field called lenght and the B) second case is a Object String that has a function called length()
, the function could of been called getLength()
or something else. The array type public field length is probably a hangover from C++ way of doing things.
Array Types have the following:
- The public final field length, which contains the number of
components of the array (length may be positive or zero)
- The public method clone, which overrides the method of the same name
in class Object and throws no checked exceptions
- All the members inherited from class Object; the only method of
Object that is not inherited is its clone method
Take a look at this, Array Types.