dcsimg
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Java
Expertise: Intermediate
Oct 15, 2019

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Loop the Characters of a String

Looping the characters of a string can be done via charAt() or toCharArray() as follows:

String str = "hello world";

for (int i = 0; i<str.length(); i++) {
char ch = str.charAt(i);
...
}

Or, via toCharArray():

for(char ch: str.toCharArray()) {
...
}
Octavia Anghel
 
Thanks for your registration, follow us on our social networks to keep up-to-date