Link to home
Start Free TrialLog in
Avatar of prograMNewbie
prograMNewbie

asked on

Dont understand a method


What is going on in this method? Even though its a void return type is has a return?  

  public void setVal(String val)
    {
        if (valr == null)
        {
            return;
        }
    }

Many thanks
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

You can always have return. This method effectively does nothing though
(as you wouldn't know from calling the method whether the String *was* null)
Avatar of prograMNewbie
prograMNewbie

ASKER


So is it the same as:

public void setVal(String val)
    {
        if (val == null)
        {
           
        }
    }
YES
SOLUTION
Avatar of hoomanv
hoomanv
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial

I see, thanks everyone ;)