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.
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.
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.
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.
I fixed it. Everything is working correctly. Thank you so much for your help, now I get to sleep ^_^
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 ;)