top of page
Search

String Tokenizer Class Java

  • AbhinawTripathi
  • Jun 17, 2016
  • 1 min read

String Tokenizer Class This class is useful to break a string into pieces called Tokens.These tokens are then stored in the StringTokenizer object from where they can retrieved.The code to create an object to String Tokenizer . StringTokenizer Class Methods

  • int countTokens()

  • boolean hasMoreTokens()

  • String nextToken()

Program:

/**

*

*/

package com.collectionpack;

import java.util.StringTokenizer;

/**

* @author Abhinaw.Tripathi

*

*/

public class StringTokenizerApp

{

/**

* @param args

*/

public static void main(String[] args)

{

String str="I am an Android Developer";

StringTokenizer st=new StringTokenizer(str," ");

System.out.println("The tokens are: ");

while(st.hasMoreTokens())

{

String one=st.nextToken();

System.out.println(one);

}

}

}

Output:

The tokens are:

I

am

an

Android

Developer

 
 
 

Recent Posts

See All

Comments


© 2016 by Abhinav Tripathi

  • Facebook Clean Grey
  • Twitter Clean Grey
bottom of page