使用扫描仪从控制台读取长值
import java.util.Scanner; public class LongInputOutput { //nowjava.com public static void main(String cLA[]) { Scanner myInput = new Scanner(System.in); long firstNumber, secondNumber, summation; firstNumber = myInput.nextLong(); secondNumber = myInput.nextLong(); summation = firstNumber + secondNumber; System.out.printf("%d\n", summation); System.out.printf(summation + "\n");/** from nowjava.com**/ } }