Results 1 to 6 of 6

Thread: Compiler Error

  1. #1
    jeneal is offline Member
    Join Date
    Nov 2007
    Posts
    4
    Rep Power
    0

    Default Compiler Error

    So I'm working on my final project for class and having issues getting the final part to work. Basically this program takes 5 inputs and puts them in a text file. As long as everything in the inputs it correct, it writes fine. However, the issue lies when the user does not know the city or the zipcode for the address. They are instructed to type 0, and the program will fill it in for them. This is whats not working. I am getting a compiler error on line 76 stating"invalid method declaration; return type required" I know I am close, I call feel it, I just can't figure this one out. Please help, I am trying my hardest and spent the past 12 hours working through this all, I'm ready to scream.

    Thank you.
    Last edited by jeneal; 12-13-2007 at 02:33 PM.

  2. #2
    gulapala is offline Member
    Join Date
    Dec 2007
    Posts
    11
    Rep Power
    0

    Default

    Hi jeneal
    Please check the declaration of build2dArray(String[] otherArray). It is defined as public build2dArray(String[] otherArray) without any return types. It should be either public void build2dArray(String[] otherArray) or public String build2dArray(String[] otherArray). The latter should be correct choice.

    Check it once again and compile it.
    Thanks & Regards, G.Rajasekhar

  3. #3
    daprodigy is offline Member
    Join Date
    Dec 2007
    Location
    Roggwil, Switzerland
    Posts
    8
    Rep Power
    0

    Default

    like you wrote ... the problem is line 76. the declaration:

    public build2dArray(String[] otherArray)

    this declaration misses the return-object-type. you have to write:

    public String build2dArray(String[] otherArray)

    ... then you have to edit the return values:

    line 99: return (String (city)); ... String (city) is interpreted as function call ... you can write: return city;

    same issue at line 116

    line 124: write return "";

    ... then you can compile the code.

    greets
    daprodigy

  4. #4
    jeneal is offline Member
    Join Date
    Nov 2007
    Posts
    4
    Rep Power
    0

    Default Thank you

    Both of you, thank you for responding and not making me feel like a complete fool, as I have run across quite a bit.

    If you don't mind, I have a few more questions.
    I have corrected the code as suggested, and it compiles, however when I run it, I get this "java.lang.NoSuchMethodError: main
    Exception in thread "main" " I don't know what it means, I have a main method.

    Thank you again.

  5. #5
    jeneal is offline Member
    Join Date
    Nov 2007
    Posts
    4
    Rep Power
    0

    Default

    I fixed it. Everything is working correctly. Thank you so much for your help, now I get to sleep ^_^

  6. #6
    daprodigy is offline Member
    Join Date
    Dec 2007
    Location
    Roggwil, Switzerland
    Posts
    8
    Rep Power
    0

    Default

    yepp, but ...

    once again the declaration of the method is wrong :)

    it has to be: public static void main (String[] args)

    ... don't worry ... all of us had the first steps in java ;)

    greets

    daprodigy

Similar Threads

  1. Help Finding Compiler error solution please
    By jamesr2b in forum New To Java
    Replies: 5
    Last Post: 04-30-2009, 07:07 AM
  2. How to solve "No compiler error"?
    By iceman in forum New To Java
    Replies: 5
    Last Post: 04-22-2008, 04:37 AM
  3. compiler
    By jidd in forum New To Java
    Replies: 3
    Last Post: 01-29-2008, 01:40 PM
  4. The best compiler for java
    By baltimore in forum New To Java
    Replies: 2
    Last Post: 08-06-2007, 06:10 PM
  5. Asking for the compiler
    By fernando in forum Other IDEs
    Replies: 1
    Last Post: 08-06-2007, 10:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •