Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2010
    Posts
    18
    Rep Power
    0

    Post null value exceptions

    Java Code:
    import java.util.Scanner;
    
    public class main {
    
    static String af;
    static String bf;
    
    
    public static void main(String args[]) {
    
    final double R = 1.0967 * (10000000);
    
    
    
    
    
    double lowest = Double.parseDouble(af);
    double highest = Double.parseDouble(bf);
    double answer;
    
    
    answer = R * (1 / (lowest * lowest) - 1 / (highest * highest));
    
    System.out.println(
    "Insert the lowest Energy level");
    Scanner obj = new Scanner(System.in);
    af = obj.nextLine();
    System.out.println("Now,Insert Highest Energy level");
    bf = obj.nextLine();
    System.out.println("Wave Length is " + answer);
    
    
    }
    }
    it shows null value exceptions why????

  2. #2
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    af and bf aren't initialized and you tried parsing them. Also, you should use informative variable names, something short(one or two words), which explains what the variable represents.

Similar Threads

  1. Null pointer exceptions and linked lists
    By Tsirist in forum New To Java
    Replies: 6
    Last Post: 03-19-2011, 07:39 PM
  2. Replies: 6
    Last Post: 10-18-2010, 11:40 AM
  3. Replies: 2
    Last Post: 03-19-2010, 06:30 PM
  4. Replies: 1
    Last Post: 10-28-2009, 03:39 AM
  5. [SOLVED] Null Pointer Exceptions
    By Riftwalker in forum Advanced Java
    Replies: 4
    Last Post: 09-26-2008, 04:19 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •