yeah, the use of java.util.Scanner would make it much more succinct:
import java.util.Scanner;
public class Addup {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int i1 = sc.nextInt();
int i2 = sc.nextInt();
System.out.println(i1 + i2);
}
}
> The extensive class library is however quite daunting. It appears there's a class for almost everything, and much of "programming in Java" seems to consist of "searching for the right class". Even after two years I find I cannot do much in Java without constant reference to the documentation.
I think it's fairly reasonable to not remember how to deal with user input in java when you need to remember what combination of streams and readers and buffers and scanners you need to put together to do it.
I'm not sure I could write that code right without Eclipse, or at least not without quite a few runs through the compiler and looks to the docs.. I'm not a Java guru, but I have used it quite a lot.
It's not hard in itself, but it is overly long, with a lot of things to remember.
I'm actually kind of embarassed I had so much trouble with this - I've been working on a commercial Java package for two years, but because it's GUI based I rarely have to deal with reading from the console. Real Java programmers will probably look down on me with a mixture of pity and disgust. Such is life.