Wrapper Class – Integer

 MAIN.JAVA:

import java.util.*;
public class Main {

    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner sc = new Scanner(System.in);
        System.out.println("Enter an integer");
        Integer n=sc.nextInt();
        System.out.println("The binary equivalent of "+n+"is "+Integer.toBinaryString(n));
        System.out.println("The hexadecimal equivalent of "+n+"is "+Integer.toHexString(n));
        System.out.println("The octal equivalent of "+n+"is "+Integer.toOctalString(n));
        System.out.println("Byte value of "+n+"is "+n.byteValue());
        System.out.println("Short value of "+n+"is "+n.shortValue());
        System.out.println("Long value of "+n+"is "+n.longValue());
        System.out.println("Float value of "+n+"is "+n.floatValue());
        System.out.println("Double value of "+n+"is "+n.doubleValue());


    }

}

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.