Switch to full style
General Java code examples
Post a reply

Boxing and unboxing make using wrapper classes

Sat Aug 29, 2009 2:36 pm

Code:
public class BoxingTest {
     public static void main(String args[])
     {
         // non auto boxing
         Integer x = new Integer(10);
         int y = x.intValue();
         System.out.println("Y = "+y);

         // auto boxing
         Integer z = new Integer(43);
         z++;
         System.out.println("z = "+z);


         Integer h = new Integer(44);
         System.out.println("h = "+h);

         // Comparing two refferences
         System.out.println("z == h "+(h == z ));


     }
}





Post a reply
  Related Posts  to : Boxing and unboxing make using wrapper classes
 java wrapper classes     -  
 Wrapper classes use in java     -  
 about classes     -  
 Abstract Classes in jsp     -  
 how do i create the classes XX and YY?     -  
 How to create and use classes in C++     -  
 instantiating java classes     -  
 inherited in the derived classes     -  
 Nested classes(inner class) in java     -  
 Add and Remove CSS classes to html tag dynamically     -  

Topic Tags

Java OOP