Results 1 to 11 of 11
- 07-20-2011, 04:46 AM #1
- 07-20-2011, 04:52 AM #2
Look at line 38 and see what variable could be null. Then trace back thru your code to see why that variable does not have a valid value.
- 07-20-2011, 05:01 AM #3
This is line 38 ( output.format( "%d %s %s %.2f\n",) in the class, but I am not understanding what is wrong with that line.
The blue lines are where I am seeing my errors.Last edited by bwilson0117; 07-20-2011 at 05:12 AM.
- 07-20-2011, 05:11 AM #4
There is only one variable on that line: output. So output must be null. Why is it null? That is what you have to find out. Hint: by default reference type variables are null if not initialised.
- 07-20-2011, 05:36 AM #5
So pretty much I just need to initialize output? Is that what your saying?
- 07-20-2011, 05:39 AM #6
It's upto you. Try it and see what happens.
- 07-20-2011, 05:58 AM #7
I changed
Formatter output = null;
AccountRecord accounts[] = new AccountRecord[ 4 ];
To
Formatter output = new Formatter();
AccountRecord accounts[] = new AccountRecord[ 4 ];
Now it compiles, is that what you were telling me to do?
- 07-20-2011, 06:10 AM #8
Once again it is upto you what you do. I can't tell you to do anything. But if the changes you made produce the correct results then why bother asking me.
- 07-20-2011, 06:33 AM #9
Ok. Appreciate you guys helping me.
- 07-20-2011, 01:27 PM #10
It compiled before with the null value, but it didn't execute without an error.Now it compiles,
Does it execute ok now? Or at least not give you the NullPointerException.
- 07-20-2011, 02:11 PM #11
Similar Threads
-
Exception in thread "main" java.lang.NullPointerException
By yotamoo in forum New To JavaReplies: 2Last Post: 09-22-2010, 10:31 PM -
Question about error "Exception in thread "main" java.lang.NoSuchMethodError: main
By ferdzz in forum New To JavaReplies: 5Last Post: 06-22-2010, 03:51 PM -
Exception in thread "main" java.lang.NullPointerException at LinkedList.main(Link
By kavitha_0821 in forum New To JavaReplies: 6Last Post: 07-16-2009, 03:30 PM -
Exception in thread "main" java.lang.NullPointerException at LinkedList.main(Link
By kavitha_0821 in forum New To JavaReplies: 1Last Post: 07-16-2009, 10:35 AM -
ArrayList: Exception in thread "main" java.lang.NullPointerException
By susan in forum New To JavaReplies: 1Last Post: 07-16-2007, 06:32 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks