package com.aflfte.test;
/**
* 测试包装类
* Integer数据包装类的使用,其它包装类用法类似。
* 包装类的做用就是实现字符串、基本数据类型、包装类型三者之间的互相转化
* @author john
*
*/
public class TestWrappedClass {
public static void main(String[] args) {
//基本数据类型怎样转为包装对象
Integer a=new Integer(3);
Integer b=Integer.valueOf(30);
//把包装对象转化成基本数据类型
int c=b.intValue();//手动将包装对象转为int类型
double d=b.doubleValue();//手动将包装对象转为double类型
//把字符串转成int包装类对象,内容必须为数字类型
Integer e=new Integer("123");
Integer f=Integer.parseInt("999888");
//把包装类对象转成字符串
String str=f.toString();
//常见的常量
System.out.println("int类型最大的整数为:"+Integer.MAX_VALUE);
}
}
« 包装类的自动装箱与自动拆箱
|
二分法查找写法(折半检索)»
|