Results 1 to 6 of 6
Thread: Compiler Error
- 12-13-2007, 11:44 AM #1
Member
- Join Date
- Nov 2007
- Posts
- 4
- Rep Power
- 0
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 01:33 PM.
- 12-13-2007, 12:36 PM #2
Member
- Join Date
- Dec 2007
- Posts
- 11
- Rep Power
- 0
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
- 12-13-2007, 12:39 PM #3
Member
- Join Date
- Dec 2007
- Location
- Roggwil, Switzerland
- Posts
- 8
- Rep Power
- 0
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
- 12-13-2007, 01:13 PM #4
Member
- Join Date
- Nov 2007
- Posts
- 4
- Rep Power
- 0
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.
- 12-13-2007, 01:31 PM #5
Member
- Join Date
- Nov 2007
- Posts
- 4
- Rep Power
- 0
I fixed it. Everything is working correctly. Thank you so much for your help, now I get to sleep ^_^
- 12-13-2007, 01:31 PM #6
Member
- Join Date
- Dec 2007
- Location
- Roggwil, Switzerland
- Posts
- 8
- Rep Power
- 0
Similar Threads
-
Help Finding Compiler error solution please
By jamesr2b in forum New To JavaReplies: 5Last Post: 04-30-2009, 06:07 AM -
How to solve "No compiler error"?
By iceman in forum New To JavaReplies: 5Last Post: 04-22-2008, 03:37 AM -
compiler
By jidd in forum New To JavaReplies: 3Last Post: 01-29-2008, 12:40 PM -
The best compiler for java
By baltimore in forum New To JavaReplies: 2Last Post: 08-06-2007, 05:10 PM -
Asking for the compiler
By fernando in forum Other IDEsReplies: 1Last Post: 08-06-2007, 09:04 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks