Create Integer using its constructors
Integer(int value)
- Creates an Integer object for the int value.
Integer(String s)
- Creates an Integer object for the int value indicated by s.
public class Main {
public static void main(String[] args) {
Integer integer1 = new Integer("1");
Integer integer2 = new Integer("2");
System.out.println(integer1);
System.out.println(integer2);
}
}
The output:
1
2
Create Integer objects from int literal and string representation
public class Main {
public static void main(String[] args) {
Integer intObj1 = new Integer(10);
Integer intObj2 = new Integer("10");
System.out.println(intObj1);
System.out.println(intObj2);
}
}
The output:
10
10
Home
Java Book
Essential Classes
Java Book
Essential Classes
Integer:
- Integer class
- Max, min value of an integer type variable
- Create Integer using its constructors
- Return an integer value as byte, double, float, int, long and short
- Compare two integer values
- Decode a string and return an integer value
- Convert string to integer
- Convert integer to string
- Reverse and rotate the integer in binary format
- Bit oriented operation
- Return system property as integer
- Get the leading and trailing zeros
- Get the sign of an Integer
- Convert integer to binary, hexdecimal and octal format