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.  
  13. Map<Integer,Integer> st = new HashMap<Integer,Integer>();
  14. Scanner s = new Scanner(System.in);
  15.  
  16. // compiles with no issues:
  17. int i = 0;
  18. int key;
  19. while ((s.hasNextInt()) && (key = s.nextInt()) >= 0){
  20. st.put(key, i);
  21. i++;
  22. }
  23.  
  24. // this, using key after the loop, would generate an uninitialized error:
  25. //System.out.println(key);
  26.  
  27. }
  28. }
Success #stdin #stdout 0.06s 711680KB
stdin
Standard input is empty
stdout
Standard output is empty