Results 1 to 9 of 9
Thread: Null pointer Exception
- 04-03-2007, 09:38 AM #1
Member
- Join Date
- Mar 2007
- Posts
- 41
- Rep Power
- 0
- 04-03-2007, 11:41 AM #2
Senior Member
- Join Date
- Mar 2007
- Posts
- 134
- Rep Power
- 0
This may be the first exception one find in his code , Best coding practices will make this exception disappear from your code.
This exception simply say ,that used object is null
to avoid that always use a null checkingJava Code:String f = null ; System.out.println("this will cause null pointer exception "+ f.length());
Java Code:String f = null ; if(f!==null) System.out.println("this will cause null pointer exception "+ f.length());
- 04-06-2007, 02:41 PM #3levent Guest
Yes, this is one of the first things a Java programmer need to interpret. To understand it fully, you need to learn objects and their references.This may be the first exception one find in his code
When you see a null pointer exception. You should go to the line specified in the error and check if there might be any null references there. To do that you can add basic "if statements" for your object references used around that line (just like goldhouse did for f variable in the above code.). Once you found the null reference variable, you can fix the problem by changing the code there. This step is application specific: you might need to make sure that no null reference is there or you can allow null references but control the program flow for not getting a null pointer exception.Last edited by levent; 04-06-2007 at 02:43 PM.
- 08-12-2008, 01:36 PM #4
Member
- Join Date
- Aug 2008
- Posts
- 11
- Rep Power
- 0
hello, how are you?
- 02-05-2010, 10:47 PM #5
always avoid to Null Pointer Exception from this method
try{
// some code
}catch(NullPointerException e)
{
// code that shows error descroption
}Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
-
No, this is a very bad idea as this will just mask bad program design. Better is to write code that avoids NullPointerExceptions in the first place. With practice you will get better at doing this.
Edit: also, isn't this thread a bit long in the tooth to be replying to? It's over a year old.Last edited by Fubarable; 02-05-2010 at 11:15 PM.
- 02-06-2010, 11:28 AM #7
i think when problem is solved or thread is old it should be locked.
because i never seen the date to thread when posting a reply ;)Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
- 09-05-2010, 06:31 PM #8
Member
- Join Date
- Sep 2010
- Posts
- 1
- Rep Power
- 0
having problem w\virtual radio for lg rumor touch
hi, new , im having a problem with trying to get virtual radio on my lg
i down loaded to pc jad & jar files then to memory card then to phone it comes on for a sec then i get this message unaccepted exception the application caused an error and will be terminated nullpointer exception
please help its driving me crazy want to listen to radio on phone
thanks
-
Is this a program that you yourself have written in Java? If so, the error message will tell you which line in the source code is causing the exception. If not, then not much we can do other than to tell you to contact your vendor. This would be way beyond the scope of this forum.
Edit: well, you never responded, so I assume that it's the latter issue, that you're not a Java developer but rather a consumer in which case you should contact the vendor. If I'm wrong and you are a developer, then please start a new thread for your question. Given the age of this one, I'm locking it.Last edited by Fubarable; 09-05-2010 at 07:29 PM.
Similar Threads
-
Null pointer exception error
By brownie_jedi in forum New To JavaReplies: 3Last Post: 03-15-2008, 06:27 AM -
Trouble with factory method - unhandled exception type Exception
By desmond5 in forum New To JavaReplies: 1Last Post: 03-08-2008, 06:41 PM -
What is NULL
By bugger in forum New To JavaReplies: 1Last Post: 01-09-2008, 04:55 PM -
parameters=null
By mary in forum Java ServletReplies: 1Last Post: 07-13-2007, 04:29 PM -
statement null pointer exception
By bbq in forum JDBCReplies: 1Last Post: 07-05-2007, 04:23 AM


LinkBack URL
About LinkBacks


Bookmarks