I am trying to check if an array lies within a LinkedList or even Stack structure, as so:
LinkedList<int[]> list = new LinkedList();
int foo = new int[]{1,2,3};
int bar = new int[]{1,2,3};
list.addLast(bar);
if(list.contains(foo)) {
System.out.print("I found foo!");
} else {
System.out.print("I didn't find foo.");
}
this returns "I didn't find foo".
Same result when I try if (Stack.search(foo) != -1)
which would succeed if foo
were found in the Stack
.
How do I search a LinkedList or other Vector/List-type structure for a specific array?