StringTokenizer用法
import java.util.StringTokenizer; public class StringTokenizerTest { public static void main(String[] args) { String str="数学::英语::语文::化学"; StringTokenizer st=new StringTokenizer(str,"::"); System.out.println(st.countTokens()); while(st.hasMoreTokens()) { System.out.println(st.nextToken()); } } }