Beginner advice: string.length () and string []. Length problem

Category: Java SE
 
scy0109
2009-03-26 08:53:10

Sponsored Links
We often write this
String [] ss = new String [3];
for (int i = 0; i <ss.length; i + +)
........................

and
String abc = " wo ";
int j = abc.length ();

I ask, String.length () is a method of the String class, but String []. length do not need braces? ? (I have not found the document which jdk similar java.lang.String [] stuff)

Sponsored Links

linyong547364
2009-03-26 08:58:14
String.length () is the String class in a method, can be found in the api.
String []. length of the array is a read-only attribute, and the array is actually a method of holding the object is a container, but with the List, Map class vessel is different, the array is not a defined class, this is rather special, it is only a read-only attribute length, it is not found in the api.
peaktime2300
2009-03-26 09:03:32
String.length ():
a class (as a class, promising without brackets) in a way (because it is a method, so to add parentheses).

String []. length:
a variable (because there is an array, so to add in parenthesis) of an attribute (because it is a property, so without parentheses) .
pyunsong
2009-03-26 09:20:31
one is the method
one class of object attribute.
yanruqing
2009-03-26 09:34:18
array length used. LENGTH
character string with a deputy. LENGTH ()
ckwd1001
2009-03-26 09:47:46
This problem should own to figure it out. ! ~
ly5890
2009-03-26 10:05:01
popular talk:
String.length (): returns the length of the string
String []. Length: returns the length of the array, the array that defines how much Members
entirely different concepts, I hope not to confuse the landlord.
shanhouxue
2009-03-26 10:24:21
jerrysoft (AKI) has made it very clear it.

String []. length is an attribute
String.length () is a method
arbrl566
2009-03-26 10:27:35
one is a method and a is an attribute, what is not clearly Yeah Yeah
java doc in there, how will finding it
damodaokes
2009-03-26 10:37:57
Will String []. length of this property, I have the jdk api documentation found inside how ah? ?
this String [] Where?
jiangjohnson
2009-03-26 10:48:14
I checked java2 sdk documentation, use the keyword check "length", checked down it seems that way, there is a small parenthesis?
yjhxhq
2009-03-26 11:07:35
Array object's length property on how to find the document from the jdk?
zynbgr168
2009-03-26 11:14:50
I understand, in fact, there is no doubt in the document to find the reason.
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.