谁帮我写一个超简单的JAVA程序

来源:百度知道 编辑:UC知道 时间:2024/06/04 03:32:13
就是
输2个数字然后可以得出相加.......
想了解一下JAVA
scanner要导包
怎么导...............
不要骂我笨..我确实很笨

import java.io.*;
public class Test{
public static void main(String args[]) {
int a,b;
try{
BufferedReader firstNumber=new BufferedReader(new InputStreamReader(System.in));
BufferedReader secondNumber=new BufferedReader(new InputStreamReader(System.in));
a=Integer.parseInt(firstNumber.readLine());
b=Integer.parseInt(secondNumber.readLine());
System.out.println("a+b="+(a+b));
}catch(Exception e){
e.printStackTrace();
}
}
}
输入一个数 按一次Enter

很简单的。
public class Test{

public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int i=sc.nextInt();
int j=sc.nextInt();
system.out.print(i+j);

}

}
scanner要导包。

java 是完全面向对象的语言,这样c++ 有点不同
class test
{
public static void main(String args[])
{
int a,b;