![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 package xuexi; 2 3 import java.util.Scanner; 4 5 public class Lianxi { 6 7 public static void main(String[] args){ 8 9 System.out.println("请输入1数字并回车"); 10 Scanner in = new Scanner(System.in); 11 int i1=in.nextInt(); 12 System.out.println("请输入1组数字并回车"); 13 int i2=in.nextInt(); 14 int i3=i1+i2; 15 System.out.println("2组数字之和="+i3); 16 17 18 19 } 20 21 }
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 package xuexi; 2 3 import java.util.Scanner; 4 5 public class Fenzhiyuju { 6 7 public static void main(String[] args) { 8 9 Scanner in = new Scanner(System.in); 10 int a = 1; // 1.短袖 2,长袖 11 System.out.println("请选择类型(1,短袖 2,长袖)"); 12 a = in.nextInt(); 13 14 if (a == 1) { 15 System.out.println("我要买短袖"); 16 System.out.println("请选择颜色:(1,表示白色,2表示黑色)"); 17 int b = in.nextInt(); 18 if (b == 1) { 19 System.out.println("我选择了白色"); 20 } else { 21 System.out.println("我选择了黑色"); 22 } 23 } 24 25 else { 26 System.out.println("我选择了长袖"); 27 System.out.println("请选择颜色(1,表示黄色,2,表示绿色)"); 28 int c = in.nextInt(); 29 if (c == 1) { 30 System.out.println("我选择了黄色"); 31 } else { 32 System.out.println("我选择了绿色"); 33 } 34 35 } 36 System.out.println("这是你要的衣服请收好"); 37 38 } 39 }
import java.util.Scanner; // 引用
Scanner in = new Scanner(System.in);
a = in.nextInt();