Java – what is the difference between length and length?
•
Java
See English answer > length and length () in java7
arrayone.length;
However, for things like array lists or strings, you end up with a bracket. For example, the length of string is as follows:
stringone.length();
What is the key reason and how do you know when to put parentheses or now?
Solution
.length;
.length;
Direct access to a field member
.length();
Calls a method (i.e., accessor) that accesses a farm member
In the case of string, this is expected because it is immutable
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码