aspose file tools*
The moose likes Beginning Java and the fly likes Error code:This method must return a result of  type int Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Error code:This method must return a result of  type int" Watch "Error code:This method must return a result of  type int" New topic
Author

Error code:This method must return a result of type int

nicole poirier
Greenhorn

Joined: Apr 03, 2013
Posts: 6
I'm new to Java and not entirely sure as to why I keep getting the error message "This method must return a result of type int" this is my code:
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

If it gives that error, then you're using a horrible compiler or IDE. The only error it should give is that you're missing a closing brace } at the end.
nicole poirier
Greenhorn

Joined: Apr 03, 2013
Posts: 6
Sorry, must have missed the last } when copying it onto here. I'm using eclipse and it won't let me run the file because of this error?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Don’t go back to your old post and correct an error which has been pointed out to you. That makes Jeff’s reply look like nonsense.
You should use an indentation convention (one available here, which doesn’t make the serious error of saying you can use tabs) and follow it religiously. You can program it into Eclipse as a project property and then use ctrl‑A‑ctrl‑I to impose indentation.

But you ought not to use an IDE at all if you are a beginner.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39436
    
  28
Why are you using a counting method on Strings when the String class has lots of methods, one of which does exactly what you want. And faster.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

nicole poirier wrote:Sorry, must have missed the last } when copying it onto here. I'm using eclipse and it won't let me run the file because of this error?


Eclipse does not give "This method must return a result of type int" for that code. That code compiles fine. You can't run it because there's no main method.
 
jQuery in Action, 2nd edition
 
subject: Error code:This method must return a result of type int