|
-
November 2nd, 2011, 11:21 AM
#15
Re: NullPointer/warnings
 Originally Posted by AlexVV
You assign:
Code:
allTxt = br.readLine();
followed by
Code:
cap = allTxt.length();
without checking if allTxt is null.
If br.readLine() returns null, allTxt is null.
If allTxt is null, you get a null pointer exception thrown.
It is thrown because you are trying to use a reference (allTxt) which is pointing to nothing (null), not the assignment of cap.
Wouldn't I want to check if br.readLine() is null?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|