Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (2.6k 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)
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

29.3k questions

30.6k answers

501 comments

104k users

Browse Categories

...