First Submition woes.

Write here if you have problems with your Java source code

Moderator: Board moderators

First Submition woes.

Postby raisdead » Thu Dec 30, 2010 7:31 pm

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.
raisdead
New poster
 
Posts: 6
Joined: Thu Dec 30, 2010 7:25 pm

Re: First Submition woes.

Postby raisdead » Wed Jul 20, 2011 4:21 am

It appears that my scanner will through an exception when Scanner receives the EOF.

Source: viewtopic.php?f=16&t=45714
raisdead
New poster
 
Posts: 6
Joined: Thu Dec 30, 2010 7:25 pm


Return to Java

Who is online

Users browsing this forum: No registered users and 1 guest