封装类

来源:互联网 发布:闻道网络 编辑:程序博客网 时间:2024/06/10 23:34

 

针对八种基本数据类型定义的相应的引用类型-封装类。
 
基本数据类型
封装类
boolean
Boolean
byte
Byte
short
Short
int
Integer
long
Long
char
Character
float
Float
double
Double

 

class Test
{
 //封装类是只读的,它的值是不能修改的
 public static void main(String[] args)
 {
  int i=3;
  Integer in=new Integer(i);//封装类**************整形类构造函数
  int j=in.intValue();//取值
  System.out.println("j="+j);
  String str=in.toString();//*********************整形到字符串
  System.out.println("str="+str);
  
  String str2="134";
  System.out.println(Integer.valueOf(str2));//字符串到整形
 }
}