I am trying to print "Contains", however, the HashSet is not detecting the Integer[] value. Does it have to do with it being Passed By Reference? How can I overcome this if I do not want to pass the actual Integer[] object into the method's arguments?
import java.util.*;
public class passByReference2{
public static void method(HashSet<Integer[]> visited){
Integer[] n = {1, 2};
if (visited.contains(n)){
System.out.println("Contains");
}
}
public static void main(String[]args){
HashSet<Integer[]> visited = new HashSet<Integer[]>();
Integer[]v = {1, 2};
visited.add(v);
method(visited);
}
}