How can I iterate through a string in Java?
I'm trying to use a foreach style for loop
for (char x : examplestring) {
//action
}
If you want to use enhanced loop, you can convert the string to charArray
for (char ch : exampleString.toCharArray()) {
System.out.println(ch);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With