Results 1 to 10 of 10
Thread: NullPointerException
- 03-26-2009, 04:07 AM #1
Member
- Join Date
- Mar 2009
- Posts
- 10
- Rep Power
- 0
- 03-26-2009, 04:32 AM #2
Senior Member
- Join Date
- Dec 2008
- Posts
- 526
- Rep Power
- 0
Perhaps some array components are not initiated. It is al depends of the method param content. What and how uses the method...
- 03-26-2009, 04:38 AM #3
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
You check the null value only for the first element of the array. What happen if the second element is null. You get the NullPointerException. That's what happen in your code.
- 03-26-2009, 04:49 AM #4
Member
- Join Date
- Mar 2009
- Posts
- 10
- Rep Power
- 0
Eranga, there is m++, does it work
- 03-26-2009, 04:55 AM #5
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Ya, m value change accordingly. Should work.
Can you show your complete error message.
- 03-26-2009, 04:56 AM #6
i think there's a problem on or while loop
for example your
mpdata.lenght = 1 (modata[0] = "test")
m = 0;
the fist loop is ok but because m = 0 and address 0 is existing in your array
then when it m = 1
address 1 is not an exiting arrayIt's easy to write a code that computers can understand...
... the challenge is to write a code that humans can understand
- 03-26-2009, 04:59 AM #7
Member
- Join Date
- Mar 2009
- Posts
- 10
- Rep Power
- 0
The full error is here
Exception in thread "main" java.lang.NullPointerException
at MPD.printdata(MobilePhoneDatabase.java:122)
at MPD.main(MobilePhoneDatabase.java:167)
Process completed.
The line 122 is exactly the error resist, the for loop
The line 167 is the main method call to printdata method
- 03-26-2009, 01:44 PM #8
Have you checked to be sure that the array has data? Does anything get printed ? Does it fail on the first element?
Luck,
CJSLChris S.
Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.
- 03-26-2009, 10:37 PM #9
Member
- Join Date
- Mar 2009
- Location
- Schenectady, NY
- Posts
- 11
- Rep Power
- 0
The array itself may be null. Check that mpdata is not null.
SoftSlate Commerce Java Shopping Cart
www.softslate.com
- 03-26-2009, 10:51 PM #10
Senior Member
- Join Date
- Sep 2008
- Posts
- 564
- Rep Power
- 5
Similar Threads
-
NullPointerException I NEED HELP
By mayhewj7 in forum New To JavaReplies: 2Last Post: 02-13-2009, 08:03 AM -
NullPointerException
By adeeb in forum AWT / SwingReplies: 3Last Post: 06-11-2008, 08:42 AM -
NullPointerException
By mensa in forum Java 2DReplies: 5Last Post: 05-03-2008, 11:19 PM -
NullPointerException
By ravian in forum New To JavaReplies: 2Last Post: 12-07-2007, 04:20 PM -
NullPointerException
By Feng in forum New To JavaReplies: 5Last Post: 11-24-2007, 07:51 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks