My program is getting compiled and executed without any errors and halfway through my program the error is being shown. I checked the code and it seemed to have a problem with the following part of the code:
student s[]=new student[10];
report(student s1[])
{
this.s=s1;
}
String highmath()
{
int temp=s[0].math;
String name=s[0].sname;
for(int i=0;i<s.length;i++)
{
if(s[i].math>temp)
{
temp=s[i].math;
name=s[i].sname;
}
}
return name;
}
Error exception in thread main java.lang.NullPointerException at report.highmath(stdapp.java.40)