Tagged Questions
47
votes
9answers
36k views
What is the easiest/best/most correct way to iterate through the characters of a string in Java?
StringTokenizer? Convert the String to a char[] and iterate over that? Something else?
7
votes
6answers
5k views
Fastest way to iterate over all the chars in a String
In Java, what would the fastest way to iterate over all the chars in a String, this:
String str = "a really, really long string";
for (int i = 0, n = str.length(); i < n; i++) {
char c = ...
1
vote
3answers
283 views
Match arguments to first argument
Okay I have to write a program that accepts 2 or more arguments and searches the second and remaining arguments for a matching argument.
for example the output would be:
./a 3 h 4 9 3
3 found
...