I solved problem 594 (One little two little three little Endians) a while a go and though I should check my answer so I submitted it and after playing around with the class name (It needed to be Main (Thanks! for the info!)) I submitted the code and I got Run time Error. When I put a try { .. } catch (Excpetion e) { ... } around all of my code in the main method it was accepted. Can anyone explain why this is the case? I would paste all of my code but I would not want to give the solution away...
- Code: Select all
import java.util.Scanner;
public static void main(String[] args) {
try {
Scanner in = new Scanner(System.in);
String line = in.nextLine();
while(!line.equals("")) {
int thisEndian = Integer.parseInt(line);
int thatEndian = flipEndian(thisEndian);
System.out.println(thisEndian +" converts to "+thatEndian);
line = in.nextLine();
}
} catch (Exception e) {
}
}
P.S. I just pasted my main method It is in a Main.java file with the correct Class definition as it was accepted.