Hi,
I'm just learning java so bare with me!! i'm just modify some examples i've read through in a book and keep getting the following error at the if statement. could someone tell me what it means and the possible solution??
Error: "unreported exception java.io.IOException; must be caught or declared to be thrown"
Thank you very much
Jon
This is all in public static void main:
|
Code:
|
double transaction;
String line;
java.io.BufferedReader stream_in;
stream_in = new java.io.BufferedReader(new java.io.InputStreamReader(System.in));
System.out.println("Input the transaction amount.");
System.out.flush();
if ((line=stream_in.readLine()) !=null) //the error appears here?
transaction = Double.valueOf(line).doubleValue();
else
transaction = 0;
wallet[0].chargeIt(transaction);
System.out.println("New Balance: £ " + wallet[0].getBalance()); |