fork 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[] countryNames = new String[100];
  13. int[] populationNum = new int[100];
  14. Scanner scan = new Scanner(System.in);
  15. int i = 0;
  16. while(scan.hasNext()) {
  17. countryNames[i] = scan.nextLine();
  18. if (scan.hasNext()) populationNum[i] = scan.nextInt();
  19. if (scan.hasNext()) scan.nextLine(); // Go to the next line
  20. i++;
  21. }
  22. for (int j = 0 ; j != i ; j++) {
  23. System.out.println(countryNames[j] + " " + populationNum[j]);
  24. }
  25.  
  26. }
  27. }
Success #stdin #stdout 0.1s 380736KB
stdin
Ghana
24333000
Brazil
193364000
Australia
23480970
Nigeria
170123000
Papua New Guinea
6888000
Mexico
108396211
Egypt
79221000
Iran
75078000
Myanmar
50496000
Belgium
10827519
Tuvalu
10000
russia
141927297
stdout
Ghana 24333000
Brazil 193364000
Australia 23480970
Nigeria 170123000
Papua New Guinea 6888000
Mexico 108396211
Egypt 79221000
Iran 75078000
Myanmar 50496000
Belgium 10827519
Tuvalu 10000
russia 141927297