import java.util.Scanner;
public static void main (String [] args)
{
Scanner p = new Scanner(System.in);
String w;
System.out.print("Enter something :"); w = p.next();
String[] m = w.split("\\s+");
for (int i=0; i<m.length;i++){
System.out.println(m[i]);
}
}
}
if i input: a s d
the output is: a only