Scanner scanner = new Scanner(System.in); int a,b; while(scanner.hasNext()){ a=scanner.nextInt(); b=scanner.nextInt(); System.out.println(a+b); }