java输入两个整数,求和.

import java.util.Scanner;
public class Test08{
public static void main(String[] args){
//输入两个整数,求和.
Scanner in = new Scanner(System.in);
int n1=0,n2=0,sum=0;
System.out.print("请输入第1个数:");
n1 = in.nextInt();
System.out.print("请输入第2个数:");
n2 = in.nextInt();
//两数相加求和
sum=n1+n2;
//打印结果
System.out.println(n1+" + "+n2+" = "+sum);

}
}

你可能感兴趣的:(java输入两个整数,求和.)