public static void main(String[] args) {
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(System.in));
try {
String string=bufferedReader.readLine();
System.out.println("hhhh"+string);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
传统;以字符读入。跟读文件一样。
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
while (in.hasNextInt()) {
int a = in.nextInt();
int b = in.nextInt();
//String c =in.nextLine();
System.out.println(a + b);
}
}
}