keywords
  • string ---split
  • string array
  • for loop
  • do while loop
 

import java.io.*;
import java.lang.String.*;
//javac string_split.java
class string_split{
public static void main(String arguments[])throws IOException
{
InputStreamReader isr = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(isr);
//needs throws IOException
System.out.print("Type some thing : ");
String str =br.readLine();
String[] words = str.split (" ");
int n1 = words.length;
System.out.println ("No of words are : " +n1);
System.out.println("--for loop: ");
for (int i =0; i <= n1-1; i++)
{
System.out.println ("\t " + i + " " + words[i]);

}//end for loop
System.out.println("--do while loop: ");
int x = 0;
do {
System.out.println ("\t " + x + " " + words[x]);
x++;

}while(x <= (n1-1));
}
}