我实现了一些代码,包括队列,当运行它,我得到一个NullPointerException.Please帮我解决它。我现在只是编写代码的缩写形式。的NullPointerException在队列
import java.util.*;
class ex
{
public static void main(String args[])throws IOException
{
Scanner in=new Scanner(System.in);
int i;
String s;
int n=in.nextInt();
Queue<Integer> q=null;
for(i=0;i<n;i++)
{
q.add(i);//I get the error in this line
}
System.out.println(q.size());
}
}