package com.programming.java;
import java.util.StringTokenizer;
public class StringTokenizerAPIExample {
public static void main(String[] args) {
StringTokenizerAPIExample st=new StringTokenizerAPIExample("Any random data from UI "," ");
while(st.hasMoreTokens())
{
System.out.println(st.nextToken());
}
}
}
//I got the error that the functions hasMoreTokens() and nextToken() are undefined for the type StringTokenizerAPIExample
Instructor
Yogesh Chawla Replied on 06/12/2021
Functions hasMoreTokens() and nextToken() belong to StringTokenizer API of java.util package. Run this.
import java.util.StringTokenizer;
public class StringTokenizerAPIExample {
public static void main(String[] args) {
StringTokenizer st = new StringTokenizer(
"Any random data from UI ", " ");
while (st.hasMoreTokens()) {
System.out.println(st.nextToken());
}
}
}
Ok...got it..thank you!
Sorry...But I already imported it?