Results 1 to 2 of 2
Thread: null value exceptions
- 07-14-2011, 07:05 PM #1
Member
- Join Date
- Nov 2010
- Posts
- 18
- Rep Power
- 0
null value exceptions
it shows null value exceptions why????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); } }
- 07-14-2011, 07:11 PM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
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
-
Null pointer exceptions and linked lists
By Tsirist in forum New To JavaReplies: 6Last Post: 03-19-2011, 06:39 PM -
Is it better to set array elements to null before setting the arrayreference to null?
By kreyszig in forum Advanced JavaReplies: 6Last Post: 10-18-2010, 10:40 AM -
JOptionPane.showMessageDialog(null,"Etc Etc"); - What does null actually do?
By markious in forum New To JavaReplies: 2Last Post: 03-19-2010, 05:30 PM -
Socket Exceptions not being generated, readLine not returning null
By jmlsteele in forum NetworkingReplies: 1Last Post: 10-28-2009, 02:39 AM -
[SOLVED] Null Pointer Exceptions
By Riftwalker in forum Advanced JavaReplies: 4Last Post: 09-26-2008, 03:19 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks