File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Any suggestions on making this code work? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Any suggestions on making this code work?" Watch "Any suggestions on making this code work?" New topic
Author

Any suggestions on making this code work?

michael bradly
Ranch Hand

Joined: Oct 06, 2000
Posts: 112
I am recieving this error message...
C:\JavaEx\methodTest\methodTest.java:4: missing return statement
{
Essentially I am using a recursive method to return a max value by dividing an array in half, searching each half for the maximum, then resolving which half has the max number.

[ September 14, 2002: Message edited by: michael bradly ]
[ September 14, 2002: Message edited by: michael bradly ]
Ron Newman
Ranch Hand

Joined: Jun 06, 2002
Posts: 1056
Please use the UBB "CODE" tag to reformat your code, so that indentation is preserved. My guess is that there's at least one path through that function that doesn't end at a return statement. Since the function returns int, all possible execution paths (that don't throw an exception) must end at a return statement.


Ron Newman - SCJP 1.2 (100%, 7 August 2002)
michael bradly
Ranch Hand

Joined: Oct 06, 2000
Posts: 112
I think I've resolved the problem I was having by making the base case
if (first == last)
{
return anArray[0];
}
else ...
So far it is working out in my testing.
Originally posted by Ron Newman:
Please use the UBB "CODE" tag to reformat your code, so that indentation is preserved. My guess is that there's at least one path through that function that doesn't end at a return statement. Since the function returns int, all possible execution paths (that don't throw an exception) must end at a return statement.

[ September 14, 2002: Message edited by: michael bradly ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Any suggestions on making this code work?