Finding the length of a string

String str="This is interesting";

      

How do I find the length of a string?

Terms:

1) Don't use any String methods

-1


source to share


2 answers


If you cannot use methods String

to find the length String

, you can use reflection (Hint: String#length

returns a field count

). However, seeing that this is homework, I think you may have misunderstood the question you are being asked.



+2


source


is str.length();

not allowed yet?



OR New link (StringLength.java)

0


source







All Articles