• Post Reply Bookmark Topic Watch Topic
  • New Topic

Missing Return Statement,  RSS feed

 
Khaly Silverman
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was an example of code that I'm trying to get to work, I swear I took it down just as it was written in class however mine says missing return statement.... What is wrong with it....

 
Paul Clapham
Sheriff
Posts: 22834
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


So here's the first line of the method which the compiler is complaining about. What does it mean? Well, starting at the beginning, it tells us the method is public. And it tells us that the method is static. And it tells us that the method returns an int value.

And there's the problem. You don't have a return statement anywhere in the method which returns the int value that is supposed to be returned when you print an array.

But wait a minute. Why should printing an array return an int value? Why should it return anything at all? I think that's the actual problem you need to fix.
 
Jacob Anawalt
Ranch Hand
Posts: 64
Linux Netbeans IDE Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't comment on the rest of the code since it is incomplete but public static int printArray says it will return an int but it doesn't have any return statements.
 
Khaly Silverman
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank-you, Problem solved, Should have been void, I actually did know that lol.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!