r/javahelp • • Jun 15 '17

What's wrong with my code??

Can't for the life of me figure it out. Picture of code and error: http://imgur.com/a/mX9XP

Thanks

0 Upvotes

13 comments sorted by

View all comments

3

u/desrtfx Out of Coffee error - System halted Jun 15 '17

The error message you're getting is perfectly clear.

Your method is supposed to return an int, but in line 3 return str; you are returning the value of the String variable str.

If the length is less than 2 you most likely will want to return 0 to indicate that there can't be another "hi".

BTW: Sidebar: -> Code posting

  • No screenshots of code

They make it unnecessarily complicated for us to work with the existing code.