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?

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