Java: ListA.addAll(ListB) fires NullPointerException?
- by HH
The err part is Capitalized in the code, it also comes in foreaching. Because of the abstract list, it cannot be initialized, declaration is in a static field. The lists have the same type.
import java.util.*;
public class Test
{
public static final List<String> highPrio = Arrays.asList("*","/");
public static List<String> ops;
public static void main(String[] args)
{
//ERROR HERE, why do it throw nullPointer?
ops.addAll(highPrio);
for(String s : ops)
{
System.out.println(s);
}
}
}