mardi 19 avril 2016

If Code Structure

I know basic if statement structure, but this confuses me

    public void setHandleName(String handle){
    if(handle.length() < 10){
        return;
    }

    handleName = handle;
}

It returns the value when the handle.length() is bigger than 10, isn't it supposed to be returning the value when handle.length() is less than 10?

Why does this if statement does the opposite?

if(false){ //do stuff; }

Where the if statement should be

if(true){ //do stuff; }

Sorry for the vague explanation, english is not my native language. Any help will be appreciated! Thanks!

Aucun commentaire:

Enregistrer un commentaire