Int type package Integer, int type integer
1. Integer Overview
Requirement 1: Calculate the binary, octal, and hexadecimal values of the 100 data.
Requirement 2: Determine whether a data is within the int range.
First, you need to know the int range?
To perform more operations on basic data types and facilitate operations, Java provides the corresponding class types for each basic data type. Packaging type.
Class type packaging class type
Byte Byte
Short Short
Int Integer
Long Long
Float Float
Double Double
Char Character
Boolean Boolean
Converts the basic data type to a string.
Public class IntegerDemo {public static void main (String [] args) {// No problem. // public static String toBinaryString (int I) System. out. println (Integer. toBinaryString (100); // public static String toOctalString (int I) System. out. println (Integer. toOctalString (100); // public static String toHexString (int I) System. out. println (Integer. toHexString (100); // public static final int MAX_VALUESystem.out.println (Integer. MAX_VALUE); // public static final int MIN_VALUESystem.out.println (Integer. MIN_VALUE );}}
2. Integer constructor:
Public Integer (int value)
Public Integer (String s)
Note: This string must be composed of digits.
Public class IntegerDemo {public static void main (String [] args) {// method 1int I = 100; Integer ii = new Integer (I); System. out. println ("ii:" + ii); // method 2 String s = "100"; // NumberFormatException // String s = "abc "; integer iii = new Integer (s); System. out. println ("iii:" + iii );}}