import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); while (scanner.hasNextInt()) { int x = scanner.nextInt();//输入x int y = scanner.nextInt();//输入y Data data = new Data(x, y);//引入方法中的函数 System.out.println(data.getX() + data.getY());//输出x+y } } } class Data { private int x; private int y; public Data(int x, int y) {//一开始是private,所以方法外访问不到 this.x = x;//这里一定加this.,不然就访问不到 this.y = y; } public int getX() { return x; } public int getY() { return y; } }