0
Where is the "length"
Excuse me, in the source of Java,where is the definition of "length" and how it work?
4 Answers
+ 1
please specify the contest of your question..
you would count the elements in an array? the chars in a string? [...]
+ 1
You have to Google out Java documentation on this method. Code of it is on Oracle website
0
It returns the length of a string.
ex:-String st=new String("Hello");
System.out.println(st.length()); //5
0
suppose we have
int a[4];
a.length gives output 4
a.length() gives compile error.
String s="abc";
s.length gives compile error.
s.length() gives output 3 because String is a class and s is the object of String Class.



