I am getting a NullPointerException in the statement which I've hidden. Can some1 tell me why is it so ?
import java.io.*;
class College
{
String branch,name = new String();
int avg_marks,rno;
InputStreamReader in= new InputStreamReader(System.in);
BufferedReader buf= new BufferedReader(in);
String s=new String();
void read()throws IOException
{
System.out.println("Enter name");
name=buf.readLine();
System.out.println("Enter roll no.");
s=buf.readLine();
rno=Integer.parseInt(s);
System.out.println("Enter branch");
branch=buf.readLine();
System.out.println("Enter average marks [out of 100] ");
s=buf.readLine();
avg_marks= Integer.parseInt(s);
}
void display()
{
System.out.println("NAME: "+name);
System.out.println("ROLL NO: "+rno);
System.out.println("BRANCH: "+branch);
System.out.println("AVERAGE MARKS: "+avg_marks);
}
}
class CRCE
{
public static void main(String args[])throws IOException
{
InputStreamReader in= new InputStreamReader(System.in);
BufferedReader buf= new BufferedReader(in);
String s=new String();
int i;
System.out.println("Enter total number of students in college");
s=buf.readLine();
int n=Integer.parseInt(s);
College c[]=new College[n];
for(i=0;i<n;i++)
c[i].read();
for(i=0;i<n;i++)
{
if(((c[i].branch.compareToIgnoreCase("COMPUTER"))==0)||(c[i].avg_marks>60))
{
c[i].display();
}
}
}
}