i'm very experienced with c/c++ but just recently started learning
java for a project i'm doing a school...i decided to write a simple program where the user just inputs something and it gets printed out again...this is VERY simple in c++, however, i was suprised that it wasn't so in java (since java is supposed to be so much simpler)..here is the code i wrote:
==================================================================
import java.io.*;
class SimpleInput {
public static void main(
String[] args) {
int value;
BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in));
String input;
System.out.print("Enter a number: ");
try {
input = stdin.readLine();
value = Integer.parseInt(input);
System.out.println("You entered: " + value + ".");
}
catch(IOException ioe) {
System.err.println(ioe.getMessage());
}
}
}
===============================================================
first of all, why do i need all these silly exception handling nonsense? I JUST WANT SOME SIMPLE INPUT. also, what's with all the other complicated stuff just to do what c++ simply does in a couple lines using cin/cout. i read on many sites that this is the best way to write this type of functionality in a program..i just want to know why it has to be so complicated