I tried writing a String input method and had a problem
with throwing IOException so i tried to use a try/catch statement, but then
the variable to be returned is said to be "not initialised" by the
compiler. wats the problem? can anyone help? here's the code;
public static String getString()
{
InputStreamReader input;
BufferedReader bR;
String s;
try{
input = new InputStreamReader(System.in);
bR = new BufferedReader(input);
s = bR.readLine();
}
catch (IOException e)
{
System.out.println("error");
System.exit(0);
}
return s; // there seems to be a problem with returning s!
}