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. Long wrapperOne = new Long(15);//Need to instantiate with Wrapper Constructor to avoid compilation errors
  13. long primitive = 15;
  14. Long wrapperTwo = new Long(15);
  15.  
  16. System.out.println("Wrapper Vs Wrapper: Results");
  17. if(wrapperOne == wrapperTwo) //will this be unboxed or do we need to put a explicit
  18. //condition like if(one.intValue() == three.intValue())
  19. System.out.println("Equal");
  20. else
  21. System.out.println("Not Equal");
  22.  
  23. System.out.println("Wrapper Vs Primitive: Results");
  24. if(wrapperOne == primitive) //will this be unboxed or do we need to put a explicit
  25. //condition like if(one.intValue() == two)
  26. System.out.println("Equal, means un-boxed automatically");
  27. else
  28. System.out.println("Not Equal");
  29. }
  30. }
Success #stdin #stdout 0.09s 320576KB
stdin
Standard input is empty
stdout
Wrapper Vs Wrapper: Results
Not Equal
Wrapper Vs Primitive: Results
Equal, means un-boxed automatically