I have below code which fails with IllegalArgumentException
public EnumSet<test> getData(){ // Line 1
return EnumSet.copyOf(get(test))) // Line 2
}
private Collection<Test> get(Test[] test){ //Line 1
test= test==null ? new Test[0] : test; // line 2
return Array.asList(test) //Line 3
}
if test is null , then line 2 of get function creates empty array of Test
and EnumSet.copyOf(get(test)) throws IllegalArgumentException
I dont understand why this exception is thrown ?