包装类 装箱和拆箱 integer j=200; int b=j; 转换 Integer. parseInt();

public class qxy {
  public static void main(String args[]) {
	//自动装箱jdk1.5之前
	  Integer i=new Integer(200);
	//自动拆箱jdk1.5之前
	  int a=i.intValue();
	System.out.println(a);
	  
	  
	  //自动装箱 jdk 1.5
	 Integer j=200;
	 //  自动拆箱
	int b=j;
	System.out.println(b);
  }
}
200
200
public class adjh {

	public static void main(String[] args) {
	   Scanner input=new Scanner(System.in);
	    System.out.println("请输入内容:");
	   String year=input.nextLine();
	    int a=Integer. parseInt(year);
	    System.out.println(year+1);
	    System.out.println(a+1);
	}
200
2001
201

猜你喜欢

转载自blog.csdn.net/weixin_43762083/article/details/119808843