package com.test;
import java.util.StringTokenizer;
public class StringTokenizerStudy {
public static void main(String[] args) {
StringTokenizer st = new StringTokenizer("A,B,C,D",",");
//Token : 문자열을 구성하는 단위
/*System.out.println(st.countTokens());
System.out.println(st.hasMoreTokens());
System.out.println(st.nextToken());
System.out.println(st.hasMoreTokens());
System.out.println(st.nextToken());
System.out.println(st.hasMoreTokens());
System.out.println(st.nextToken());
System.out.println(st.hasMoreTokens());
System.out.println(st.nextToken());
//System.out.println(st.nextToken());//Error
System.out.println(st.hasMoreTokens());*/
//While문으로 바꾸어 보세요
/*while(st.hasMoreTokens()){
System.out.println(st.nextToken());
}
*/
//for문으로 바꾸어 보세요
int num = st.countTokens();
for(int i=0;i<num;i++){
System.out.println(i+st.nextToken());
}
//공백으로 문자를 구분해라
StringTokenizer st1 = new StringTokenizer("0 1 2 3");
while(st1.hasMoreTokens()){
System.out.print(st1.nextToken(" "));
}
// '/'으로 문자를 구분해라.
StringTokenizer st2 = new StringTokenizer("6/7/8/9");
while(st2.hasMoreTokens()){
System.out.print(st2.nextToken("/"));
}
}
}