I’ve noticed that when doing the length of an array you write something like:
arrayone.length;
However, for such things as array lists or a string, you write a bracket on the end, such as the following for the length of the String:
stringone.length();
What is the key reason for this and how do you know when to put the brackets or now?
directly accesses a field member.
invokes a method (i.e. an accessor) to access a field member.
in the case of
String, this is to be expected since it’s immutable.