数字与字符串

package fuxi;


public class ShuziYuZifuchian {
public static void main(String[] args) {
//封转类 int 到 int对应的类类型 Integer(一般对应的是开头字母大写)
int i=5;
Integer i1=new Integer(i);
int i2=i1.intValue();
long l=1L;
Long l1=new Long(l);
//自动转为封装类
Integer i3=i;
//自动拆箱
int i4=i3;
System.out.println(Integer.MAX_VALUE);
byte b=1;
Byte i5=b;
//字符串的转化
int i6=1234567;
String s=Integer.toString(i6);
long i7=Integer.parseInt(s);
float f=3.14f;
String s1=Float.toString(f);
float f1=Float.parseFloat(s1);

}


}


Integer 的三个方法

1. getInteger(String um,int vul)  

2. parseInt(String s) 把String 类型变成int类型 

3 valueOf(String s)和2的区别是返回值不一样。


猜你喜欢

转载自blog.csdn.net/qq_37752233/article/details/72865094