0

Where is the "length"

Excuse me, in the source of Java,where is the definition of "length" and how it work?

19th Dec 2016, 1:18 AM
钱帮全
钱帮全 - avatar
4 Answers
+ 1
please specify the contest of your question.. you would count the elements in an array? the chars in a string? [...]
19th Dec 2016, 2:09 AM
Michael Isac Girardi
Michael Isac Girardi - avatar
+ 1
You have to Google out Java documentation on this method. Code of it is on Oracle website
19th Dec 2016, 3:19 AM
Maksym Zieliński
Maksym Zieliński - avatar
0
It returns the length of a string. ex:-String st=new String("Hello"); System.out.println(st.length()); //5
19th Dec 2016, 2:09 AM
Doolitha Samaranayake
Doolitha Samaranayake - avatar
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.
19th Dec 2016, 2:48 PM
Aayush Agarwal