I fixed up your code. If you have any questions, feel free to ask.
import java.io.*;
public class Life42 {
public static void main(String[] args) {
BufferedReader stdIn = new BufferedReader(
new InputStreamReader(System.in));
String input;
int a;
while (true) {
try {
System.out.print("Input a number: ");
input = stdIn.readLine(); // throws IOException on failure
a = Integer.parseInt(input); // throws NumberFormatException on failure
System.out.println(a);
if (a == 42)
System.exit(0);
} catch (NumberFormatException e) {
System.out.println("Maybe if you enter a number...");
} catch (IOException e) {
System.err.println("There was a problem reading your input.");
}
}
}
}