Tue Nov 11, 2008 10:44 pm
import java.io.*;
import java.util.*;
public class BreakStringToWord{
String str;
int count = 0;
public static void main(String[] args) {
BreakStringToWord c = new BreakStringToWord();
}
public BreakStringToWord(){
try{
InputStreamReader ir = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(ir);
System.out.print("Enter String: ");
str = br.readLine();
System.out.println("Enter String is : "+ str);
System.out.println("Breaking this string is : ");
StringTokenizer token = new StringTokenizer(str);
while (token.hasMoreTokens()){
count++;
str = token.nextToken();
System.out.println(str);
}
System.out.println("Number of Words : "+ count);
}
catch(IOException e){}
}
}
Sat Jan 14, 2012 10:59 am
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.