StringTokenizer? Convert the String to a char[] and iterate over that? Something else?
So typically there are two ways to iterate through string in java which has already been answered by multiple people here in this thread, just adding my version of it First is using
String s = sc.next() // assuming scanner class is defined above
for(int i=0; i
If performance is at stake then I will recommend to use the first one in constant time, if it is not then going with the second one makes your work easier considering the immutability with string classes in java.