Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Exception in thread "main" java.lang.NullPointerException

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default 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!
    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();
          }
        }
      }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,094
    Thanks
    48
    Thanked 2,152 Times in 2,125 Posts

    Default Re: Exception in thread "main" java.lang.NullPointerException

    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.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    nikomania (January 16th, 2013)

  4. #3
    Junior Member
    Join Date
    Jan 2013
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default 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

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,094
    Thanks
    48
    Thanked 2,152 Times in 2,125 Posts

    Default Re: Exception in thread "main" java.lang.NullPointerException

    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
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 5
    Last Post: December 9th, 2012, 01:25 PM
  2. Exception in thread "main" java.lang.NullPointerException problem.......
    By Adam802 in forum What's Wrong With My Code?
    Replies: 4
    Last Post: September 20th, 2012, 02:23 AM
  3. Replies: 3
    Last Post: December 7th, 2011, 01:03 AM
  4. Exception in thread "main" java.lang.NullPointerException
    By Tsark in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 11th, 2011, 08:39 AM
  5. Exception in thread "main" java.lang.NullPointerException
    By MryJaho in forum What's Wrong With My Code?
    Replies: 4
    Last Post: February 4th, 2011, 04:36 PM