Hello,
I am new in java, I wanna split a string like : " abc, def, ghi" and store each of tokens that I can compare token1 (abc) with token2 (def), and again compare token2 (def) with token3(ghi) until it gets the end of the file.
any comments?
Printable View
Hello,
I am new in java, I wanna split a string like : " abc, def, ghi" and store each of tokens that I can compare token1 (abc) with token2 (def), and again compare token2 (def) with token3(ghi) until it gets the end of the file.
any comments?
Go for it! We won't do that for you. Ask specific questions, format your code, include compilation and runtime errors.
here is my code:
public static void main(String[] args) {
String str = "abc, def, ghi";
System.out.println("---- Split by comma ',' ------");
StringTokenizer st2 = new StringTokenizer(str, ",");
//when there are still more tokens, place it in the array:
while(st2.hasMoreTokens()) {
String key = st2.nextToken();
System.out.println(key );
}
}
is that clear enough?
Yes, but you didn't format your code and you didn't ask a question.
Hi emma,
It may help you.
[ spoonfeeding code deleted - mod ]