0

In my class there are 2 objects, I have to get the one which has the smallest size with a method that begins with

public String smallest()

so what I've been trying to do is roughly the following...

if (object1.getSize() < object2.getSize) { 
return object1.getName; } } 
if (object2.getSize() < object1.getSize()) { 
return object2.getName; } }

but it keeps giving an error saying "return statement missing", even if I give each if statement a variable of it's own there is still the same error!

How do i fix this?

2
Contributors
1
Reply
3
Views
6 Years
Discussion Span
Last Post by sj5536
0

you have to add extra return value for the condition which dont match two if hence u have to add return for default condition or used if else block

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.