I have two Lists List<List<Integer>>
a and b, as following:
a = [[120, 0], [121, 1], [122, 2], [123, 3], [124, 4], [125, 5]]
b = [[123, 3]]
I want a simple method that returns true or false if b
contains an element ofa
.
I tried b.contains(a)
, and !Collections.disjoint(a, b)
, but to no avail. It doesn't seem to work with such deep lists.
EDIT: I'm posting the full code of my issue:
Some private variables:
private List<List<Integer>> processedCurrentCoordinate = new ArrayList<List<Integer>>();
And the main dish ( I want the first loop to be processed only if HurdlefullCoordinatesList
is included inside this.processedCurrentCoordinate
public List<Integer> getNewData(int oldPositionX, int oldPositionY, int hasFood, List<List<Integer>> HurdlefullCoordinatesList) {
do {
do {
this.currentCoordinate.clear();
this.processedCurrentCoordinate.clear();
this.newPositionX = this.modelAnt.randomposition(oldPositionX);
this.newPositionY = this.modelAnt.randomposition(oldPositionY);
this.currentCoordinate.add(newPositionX);
this.currentCoordinate.add(newPositionY);
this.processedCurrentCoordinate.add(currentCoordinate);
} while((Integer.valueOf(this.newPositionX).equals(Integer.valueOf(oldPositionX))) && (Integer.valueOf(this.newPositionY).equals(Integer.valueOf(oldPositionY))));
} while(HurdlefullCoordinatesList.contains(this.processedCurrentCoordinate));