+ 1

Using charAt

I'm trying to use charAt to compare letters to see which comes first. I don't know how to move from charAt (0) > charAt (1) to charAt (2) > charAt (3) and so on.

19th Mar 2018, 8:42 AM
[No Name]
[No Name] - avatar
3 Respuestas
+ 12
for comparing char , U can use == operator // String_value.charAt (index no.); is basic syntax
19th Mar 2018, 1:29 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 2
use a for loop, and the counting variable as argument for charAt
19th Mar 2018, 8:47 AM
Jeremy
Jeremy - avatar
+ 2
String s = "ABC"; for(int i = 0; i < s.length(); i++) { System.out.println(s.charAt(i)); }
19th Mar 2018, 10:26 AM
Ravi Chandra Enaganti
Ravi Chandra Enaganti - avatar