Skip to content

Instantly share code, notes, and snippets.

@dheshanm
Created October 12, 2015 15:47
Show Gist options
  • Select an option

  • Save dheshanm/a1749ebeb039dded089e to your computer and use it in GitHub Desktop.

Select an option

Save dheshanm/a1749ebeb039dded089e to your computer and use it in GitHub Desktop.
package tutorials.Next;
import java.io.*;
import java.util.*;
/**
* Created by Dheshan M (@D-codex) on 10/12/2015.
*/
public class StringTokens {
public static void main(String Args[]){
int n=0;
Scanner in=new Scanner(System.in);
System.out.print("Enter a String :");
String str=in.nextLine();
StringTokenizer st=new StringTokenizer(str);
while(st.hasMoreTokens()){
System.out.println(st.nextToken());
n=n+1;
}
System.out.print("The Entered String has "+n+" Tokens");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment