fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String line1 = "10 20";
  13. String line2 = "30";
  14. String line3 = " ";
  15.  
  16. String[] split1 = line1.split(" ");
  17. String[] split2 = line2.split(" ");
  18. String[] split3 = line3.split(" ");
  19.  
  20. System.out.println("linha 1 - " + split1.length + " valores");
  21. for(String value : split1){
  22. System.out.println(value);
  23. }
  24.  
  25. System.out.println("linha 2 - " + split2.length + " valor");
  26. for(String value : split2){
  27. System.out.println(value);
  28. }
  29.  
  30. System.out.println("linha 3 - " + split3.length + " valores");
  31. for(String value : split3){
  32. System.out.println(value);
  33. }
  34.  
  35. }
  36. }
Success #stdin #stdout 0.09s 27896KB
stdin
Standard input is empty
stdout
linha 1 - 2 valores
10
20
linha 2 - 1 valor
30
linha 3 - 0 valores