class Details
{
String name="a",designation="a";
int salary=0,hra=0,da=0;
int na,nb,nc;
String changenamea,changenameb,changenamec;
int netpay=0;
void get()
{
DataInputStream dis=new DataInputStream(System.in);
try
{
System.out.println("Enter name:");
name = dis.readLine();
System.out.println("Enter designation:" );
designation = dis.readLine();
System.out.println("Enter salary:");
String salarystr = dis.readLine();
salary = Integer.parseInt(salarystr);
System.out.println("Enter HRA:");
String hrastr = dis.readLine();
hra = Integer.parseInt(hrastr);
System.out.println("Enter DA:");
String dastr = dis.readLine();
da = Integer.parseInt(dastr);
}
catch(IOException e)
{
System.out.println("Caught an error");
}
}
.....
....
}
class Employee
{
public static void main(String args[])throws IOException
{
try
{
Details[] obj = new Details[25];
DataInputStream br=new DataInputStream(System.in);
int count,loopv=1,count1,validator=1;
System.out.println("Enter employee details ");
for(count = 1; loopv != 0; ++count)
{
validator = count;
obj[count].get();
System.out.println("input captured");
obj[count].calc();
System.out.println("Do you wish to add details for another employee?enter 0 if no..");
String temp = br.readLine();
loopv = Integer.parseInt(temp);
}
for(count1 = 1; count1 <= validator; ++count1)
{
obj[count1].put();
}
}
catch(NullPointerException e)
{
System.out.println("Error:" + e);
}
}
}
Please help me resolve the null pointer exception in this..
Thanks in advance..
*Edited to add the [ code] tags
This post has been edited by pbl: 12 July 2009 - 09:13 PM

New Topic/Question
Reply




MultiQuote






|