Write a program in java to demonstrate valueOf() method?

class WrapperValueOf

{

                public static void main(String arg[])

                {

                                //Converting int into Integer

                                int a=20;

                                Integer i=Integer.valueOf(a);      //Converting int into Integer

                                Integer j=a;         //Autoboxing, Now compiler will write Integer.valueOf(a) internally

                                System.out.println(a+" "+i+" "+j);

                }

}

valueOf() method.PNG

, , , , , ,

Leave a Reply