+ 2

Length of string in java

How to find length of string without using length

25th Jun 2019, 6:17 AM
Pawan Kumar
Pawan Kumar - avatar
5 Respuestas
+ 6
But what is the whole point especially since the length method is just so useful and reduces code length.
25th Jun 2019, 6:43 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 5
You can use an enhanced for loop: String str = "This is a string"; int len = 0; for (String i: str.split("") len++; System.out.println(len);
25th Jun 2019, 6:38 AM
Airree
Airree - avatar
+ 1
Prometheus ¯\_(ツ)_/¯ 🇸🇬 Maybe practice purpose.
25th Jun 2019, 11:32 AM
Seb TheS
Seb TheS - avatar
+ 1
, you can use infinite loop i++ index and catch index error. too or stream of chars and count()
25th Jun 2019, 7:41 PM
zemiak
0
Complete the code to create a string containing a double quote
14th Jul 2019, 3:56 AM
G Max
G Max - avatar