
Hands on Exercise on Wrapper Class:
Write a Java code that converts integer to Integer converts Integer to String converts String to integer converts int to String converts String to Integer converts Integer to integer displays the largest and smallest values of type integer converts the decimal to binary and hexadecimal
expected output: String s = 26 Integer m = 26 String s = 26 String x = 6 integer m = 26 Integer.MIN_VALUE = -2147483648 Integer.MAX_VALUE = 2147483647 Binary: 11010 Hexadecimal: 1a

Hi Friend,
Try this:
class ConversionExample
{
public static void main(String[] args)
{
int i=26;
Integer integer=new Integer(i);
String st=integer.toString();
int no=Integer.parseInt(st);
String str=Integer.toString(no);
Integer num=Integer.valueOf(str);
int in=num.intValue();
System.out.println("int to Integer= "+integer);
System.out.println("Integer to String= "+st);
System.out.println("String to int= "+no);
System.out.println("int to String= "+str);
System.out.println("Integer to String= "+st);
System.out.println("String to Integer= "+num);
System.out.println("Integer to int= "+in);
int max=Integer.MAX_VALUE;
int min=Integer.MIN_VALUE;
System.out.println("Minimum value of integer: "+min);
System.out.println("Maximum value of integer: "+max);
System.out.println("Binary: "+Integer.toBinaryString(in));
System.out.println("Hexadecimal: "+Integer.toHexString(in));
}
}
Thanks
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.