String str = "hello\r\n" + "world";
System.out.println(str.length());
why is answer 12?
hello and world should be 10 in total.
so which of the characters (\r\n) are not counted?
length()
Moderator: admin
-
- Site Admin
- Posts: 10325
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: length()
Both are counted. That is why "hello\r\n" is 7 and "world" is 5. Total 7+5 is 12.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 4 guests