Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (4k points)
StringTokenizer? Convert the String to a char[] and iterate over that? Something else?

1 Answer

0 votes
by (46k points)

I apply a for loop to emphasize the string and use charAt() to arrange specific character to check it. Since the String is achieved with an array, the charAt() program is a regular time operation.

String s = "...stuff...";

for (int i = 0; i < s.length(); i++){

    char c = s.charAt(i);        

    //Process char

}

That's something I would do. It appears the most obvious to me.

As far as precision goes, I don't think that endures here. It is all based on your style.

Related questions

0 votes
1 answer
asked Nov 25, 2019 in Java by Anvi (10.2k points)
0 votes
1 answer
asked Jul 27, 2019 in Java by Ritik (3.5k points)
0 votes
1 answer
0 votes
1 answer
asked Aug 26, 2019 in Java by Krishna (2.6k points)

Browse Categories

...