Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.samkough.java.main;
- public class Integers
- {
- public static void main(String args[])
- {
- // This line creates an integer primitive data type.
- int a = 55;
- // An Integer wrapper class is created from the primitive int type.
- Integer b = new Integer(a);
- // The intValue() method converts the Integer to int. Likewise, the floatValue() returns a float data type.
- int c = b.intValue();
- float d = b.floatValue();
- // These three methods return a binary, hexadecimal and octal representations of the integer.
- String bin = Integer.toBinaryString(a);
- String hex = Integer.toHexString(a);
- String oct = Integer.toOctalString(a);
- System.out.println(a);
- System.out.println(b);
- System.out.println(c);
- System.out.println(d);
- System.out.println(bin);
- System.out.println(hex);
- System.out.println(oct);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment