5월 3일 내용정리
-hasMoreElements 남아있는 토큰의 여부를 boolean으로 반환
-변수명.countTokens 토큰갯수
-hasMoreElements 남아있는 토큰이 true면 nextToken()로 다음 토큰을 꺼낸다.
package study_0503;
import java.util.StringTokenizer;
public class TokenExam {
public static void main(String[] args) {
String s="of the people, by the people, for the people";
StringTokenizer st =new StringTokenizer(s," ");
System.out.println(st.countTokens());
StringTokenizer st01 =new StringTokenizer(s,",");
System.out.println(st.countTokens());
while(st.hasMoreElements()) { //hasMoreElements 남아있는 토큰의 여부를 boolean으로 반환
System.out.print(st.nextToken()+"/"); //hasMoreElements남아있는 토큰이 true면 nextToken()로 다음 토큰을 꺼낸다.
}
}