Using the combination of BufferedReader and StringTokenizer...
Here is the example...
import java.io.*;
public class Token1 {
public static void main(String[] args) throws Exception {
double sum=0;
System.out.println("Type two or more numbers separated by space
to add:(Example: 4 5.6 8.2 2");
//Using BufferedReader recognize the return key input
BufferedReader br = new BufferedReader(new InputStreamReader
(System.in));
String s1 = br.readLine();
//Using string Tokenizer will split the data using the
delimiter space.
java.util.StringTokenizer st =new java.util.StringTokenizer
(s1);
while (st.hasMoreTokens()) sum += Double.parseDouble
(st.nextToken());
System.out.println(" Sum = "+sum);} }