samedi 21 septembre 2019

How to check if a object is a type of enum in arraylist in java?

I have a simple question. Say I have an arrayList that will hold three different types from my enum below. How do I check to see if one of my items in my arraylist is a specific enum in java? For instance, how do I check to see is a object is a small through a if statement? I'm pretty new to using arraylists so I am not to sure what I can and can't do with them.

// My ArrayList...

ArrayList<sizes> myItems = new ArrayList<sizes>; 

// My enum...

     enum itemType { 

          SMALL, MEDIUM, LARGE }
}

Aucun commentaire:

Enregistrer un commentaire