I implemented some code involving queues and while running it I get a NullPointerException.Please help me to fix it.I am only writing the shorter form of that code.
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());
}
}