jeudi 14 juin 2018

How to prevent the error: null > 0 java

I currently have an enumlist. The enumlist gets filled at random, so there is a possiblity one has the value Null, that is logical because it doesn't get filled.

The problem is futher in my code i have:

if( player.Enumlist().get(CART_BLACK) > 0) {
}

Java gives a nullpointerexception. Is there something i could add to the if statement so it prevents this error?

Thanks in advantage,

Aucun commentaire:

Enregistrer un commentaire