fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.math.*;
  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. Queue<Object> q = new ArrayDeque<>();
  13. q.add(5);
  14. q.add("Foo");
  15. q.add(5d);
  16. q.add(5f);
  17. q.add(Arrays.asList(1,2,3));
  18. q.add(BigInteger.ONE);
  19.  
  20. Object toRead;
  21. while((toRead = q.poll())!=null){
  22. System.out.format("%9s > %s%n",toRead, toRead.getClass());
  23. }
  24.  
  25. }
  26. }
Success #stdin #stdout 0.1s 28308KB
stdin
Standard input is empty
stdout
        5 > class java.lang.Integer
      Foo > class java.lang.String
      5.0 > class java.lang.Double
      5.0 > class java.lang.Float
[1, 2, 3] > class java.util.Arrays$ArrayList
        1 > class java.math.BigInteger