Integer的构造方法
/*
关于Integer类的两种构造方法,有两个:
Integer(int)
Integer(String)
*/
public class IntegerTest03 {
public static void main(String[] args) {
//java9之后不建议使用这个构造方法了,出现横线表示已经过时
//将数字100转换为Integer包装类型(int ---> Integer)
Integer x = new Integer(100);
System.out.println(x.toString());
//将String类型的数字,转换为Integer包装类型。(String ---> Integer)
Integer y = new Integer("123");
System.out.println(y);
//double --> Double
Double d = new Double(1.23);
System.out.println(d);
//String --> Double
Double e = new Double("3.14");
System.out.println(e);
//100
//123
//1.23
//3.14
}
}
通过包装类的常量,获取最大值和最小值
public class IntegerTest03 {
public static void main(String[] args) {
//通过包装类的常量,来获取最大值和最小值
System.out.println("int的最大值:"+ Integer.MAX_VALUE);
System.out.println("int的最小值:"+ Integer.MIN_VALUE);
System.out.println("byte的最大值:"+ Byte.MAX_VALUE);
System.out.println("byte的最大值:"+ Byte.MIN_VALUE);
//int的最大值:2147483647
//int的最小值:-2147483648
//byte的最大值:127
//byte的最大值:-128
}
}