Finding the length of a string

String str="This is interesting";


How do I find the length of a string?


1) Don't use any String methods


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.



is str.length();

not allowed yet?

OR New link (



All Articles