Java: ListA.addAll(ListB) fires NullPointerException?

Posted by HH on Stack Overflow See other posts from Stack Overflow or by HH
Published on 2010-05-08T05:10:43Z Indexed on 2010/05/08 5:18 UTC
Read the original article Hit count: 169

Filed under:
|
|
|
|

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);
                }
        }
}

© Stack Overflow or respective owner

Related posts about java

Related posts about list