StringTokenizer

StringTokenizer

import java.util.StringTokenizer;
public class JusTest {
  public static void main(String[] main)
  {

 String key = "a_charlie_logic";
      
    StringTokenizer st = new StringTokenizer(key, "_");
        
    String str1=st.nextToken();  
    System.out.println(str1);
    System.out.println(st.countTokens());
   
    String str2=st.nextToken();
    System.out.println(str2);
    System.out.println(st.countTokens());
        
    String str3=st.nextToken(); 
    System.out.println(str3);
    System.out.println(st.countTokens());
   
 
 
 
 
 }
}

你可能感兴趣的:(StringTokenizer)