Exception in thread "main" java.lang.NullPointerException
Hello guys, i was searching for that error and I found this site, a found some similar threads but i couldnt solve this erros. please ckeck it :)
If you dont understand the meaning of some variables its because they are in my language with just latin letters! Thanks a lot!
Code java:
import java.io.*;
class Employee11{
private String Eponymia;
private String AFM;
private int Meres_Ergasias;
private double Hmeromisthio;
private float Yperories;
private float Syntelestis_Kratiseon;
Employee11(String onoma, String afm, int meres, double xrima_meras, float uper){
Eponymia = onoma;
AFM = afm;
Meres_Ergasias = meres;
Hmeromisthio = xrima_meras;
Yperories = uper;
}
public static double[] Ypol_TelikouMisthou(Employee11 pinakas[]){
double katharos[] = new double[3];
double akatharistos=0;
for(int z=0; z<pinakas.length; z++){
akatharistos=pinakas[z].Meres_Ergasias*pinakas[z].Hmeromisthio+0.2*pinakas[z].Hmeromisthio*pinakas[z].Yperories;
if(akatharistos<=15000){
katharos[z] = akatharistos-akatharistos*0.17;
} else if(akatharistos<18000){
katharos[z] = akatharistos-akatharistos*0.20;
} else if(akatharistos<25000){
katharos[z] = akatharistos-akatharistos*0.25;
} else if(akatharistos<40000){
katharos[z] = akatharistos-akatharistos*0.35;
} else {
katharos[z] = akatharistos-akatharistos*0.45;
}
}
return katharos;
}
}
public class Employee1 {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
Employee11 pinakas[] = new Employee11[3];
for(int z=0; z<pinakas.length; z++){
System.out.println("Parakalo pliktrologiste to onomateponumo sas");
String onoma = br.readLine();
System.out.println("Parakalo pliktrologiste to AFM sas");
String afm = br.readLine();
System.out.println("Parakalo pliktrologiste tis meres ergasias sas");
int meres = Integer.parseInt(br.readLine());
System.out.println("Parakalo pliktrologiste to hmeromisthio sas");
double xrima_meras = Double.parseDouble(br.readLine());
System.out.println("Parakalo pliktrologiste to suntelesti uperorias sas");
float uper = Float.parseFloat(br.readLine());
pinakas[z] = new Employee11(onoma, afm, meres, xrima_meras, uper);
double kathara[] = new double[3];
kathara = Employee11.Ypol_TelikouMisthou(pinakas);
for(z=0; z<kathara.length; z++){
System.out.println(kathara);
System.out.println();
}
}
}
}
Re: Exception in thread "main" java.lang.NullPointerException
Quote:
i couldnt solve this erros
Please copy the full text of the error messages and paste it here.
Please edit your post and wrap your code with code tags not quote tags
[code=java]
<YOUR CODE HERE>
[/code]
to get highlighting and preserve formatting.
Re: Exception in thread "main" java.lang.NullPointerException
here it is
Exception in thread "main" java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(Floa tingDecimal.java:1011)
at java.lang.Float.parseFloat(Float.java:452)
at Employee1.main(Employee1.java:53)
Java Result: 1
Re: Exception in thread "main" java.lang.NullPointerException
Quote:
Exception in thread "main" java.lang.NumberFormatException: empty String
at sun.misc.FloatingDecimal.readJavaFormatString(Floa tingDecimal.java:1011)
at java.lang.Float.parseFloat(Float.java:452)
at Employee1.main(Employee1.java:53)
That is a different error than the one in the title for this thread.
On line 53 the parsefloat() method was called with bad data. Make sure to pass a valid String to the method or catch the exception using a try{} catch block