• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Missing Return Statement,

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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....

 
Sheriff
Posts: 28414
102
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 coderanch. 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.
 
Ranch Hand
Posts: 64
Netbeans IDE Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank-you, Problem solved, Should have been void, I actually did know that lol.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic