Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Nullpointer exception??

843789Apr 18 2010 — edited Apr 19 2010
Hi all,

I have the Nullpointer exception in my program and cannot pin point where the error is. I have a class called readText that reads ID's from text files. The IDs are 20 characters(all numerals) and i use substring [substr(0,21)] to pick it. I also have a method that is called from the readText class and this method have a SQL query. In the method are if-else statement to checks if the ID's equals either:
condition 1- IDs are 8 digits,
condtition 2- IDs are 7 digits
condtion 3- if its none of the above, then its invalid ID

The class and method have their own exception handling. Now, just recently i ran the program and the nullpointer exception came up. I checked the text and notice that there was an 9 digit ID. I debugged it and discovered that the problem was with the method conditions i set(like above). However, the twist is the error got caught by readText class exception handling and not the one in the method. Does that mean the error is in the class or method?????? Because if it was from the method, then it would have been caught in the method.

Can anyone help me out with this cause i've wecked my brain already just trying to figure it out.

Thanks yall

okun
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 17 2010
Added on Apr 18 2010
4 comments
227 views