The "Java Grammar Basics Course" category column of this blog will implement all the topics of AcWing's basic grammar courses in Java language. The solution will be updated from time to time. Welcome everyone to exchange and learn.
1. Title
Enter two integers and find the sum of these two integers.
Input format
Input two integers A, B, separated by spaces, 0≤A,B≤108
Output format
Output an integer, which represents the sum of these two numbers
Sample input:
3 4
Sample output:
7
2. Code
import java.util.Scanner; //调用Java的Scanner类,用于获取控制台的输入
public class Main
{
public static void main(String[] args) //程序的入口
{
int a,b;
Scanner scan=new Scanner(System.in);
a=scan.nextInt(); //nextInt() 是取next() 然后把字符串解析成一个int数字
b=scan.nextInt();
System.out.println(a+b);
scan.close();
}
}