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
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
No comments:
Post a Comment