mardi 15 novembre 2016

Comparing fields of object store in arraylist using iterator

I am passing an integer value address to this function. This integer value is contained by one of the object stored in Arraylist "instrHolder". Now I want to first find out which object contains this value and return the entire object of type "Instruction". Here is what I am trying -

private static Instruction getInstruction( int address) {
    Iterator<Instruction> iterator = instrHolder.iterator();
    while(iterator.hasNext()){
        if(/*condition need to know*/)
        return /*need to know*/;
    }
}

How should I write the if condition and what should be my return statement? Please help me out?

Aucun commentaire:

Enregistrer un commentaire