• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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....

 
Marshal
Posts: 28262
95
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 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.
 
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.
 
Maybe he went home and went to bed. And took this tiny ad with him:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic