Results 1 to 6 of 6
Thread: String not equal to...... :(
- 04-21-2012, 12:42 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 19
- Rep Power
- 0
String not equal to...... :(
Hi all,
I am trying to pull data from an array and I am now doing so successfully thank you to some information from 'mwr1976' :)
How ever I have this strange issue doing my head in.....
If there is nothing recorded in the array location I am pulling from I want the app to not do anything with it,
The line I am using is
if (!Toy.toys[i][3].equals(null)) {
and I have tried
if (!Toy.toys[i][3].equals("null")) {
BUT, I get
Exception in thread "main" java.lang.NullPointerException
BTW, this is a String[][] array
This also terminates my program at this point / where ever I hit a "null"
Any ideas? Thanks
- 04-21-2012, 01:07 PM #2
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
Re: String not equal to...... :(
Java Code:if (Toy.toys[i][3] != null) {
- 04-21-2012, 01:18 PM #3
Member
- Join Date
- Apr 2012
- Posts
- 19
- Rep Power
- 0
- 04-21-2012, 01:19 PM #4
Member
- Join Date
- Apr 2012
- Posts
- 19
- Rep Power
- 0
- 04-21-2012, 02:44 PM #5
Senior Member
- Join Date
- Apr 2012
- Location
- New York State of Confusion, USA
- Posts
- 137
- Blog Entries
- 1
- Rep Power
- 0
Re: String not equal to...... :(
You're welcome. the .equals will only work for another string or a string literal.
- 04-21-2012, 10:41 PM #6
Member
- Join Date
- Apr 2012
- Posts
- 19
- Rep Power
- 0
Re: String not equal to...... :(
I was thinking in the line of strings for this as the array is a string array full of strings :)
However, I have learnt where the confusion was coming from so that I can work with a lot more of these in the future.
Thanks again and the extra information certainly helps.
Similar Threads
-
x input string is not equal to "x"
By monkeynote in forum New To JavaReplies: 3Last Post: 01-18-2012, 07:45 AM -
help with not equal to operator !=
By manowar689 in forum New To JavaReplies: 9Last Post: 06-15-2010, 12:10 AM -
string comparison with "=" and ".equal"
By guavajuice in forum New To JavaReplies: 9Last Post: 04-22-2010, 09:01 PM -
equal() method
By need_helpp in forum New To JavaReplies: 3Last Post: 03-09-2010, 05:57 PM -
Entering a while loop with a not equal to string
By bri1547 in forum New To JavaReplies: 9Last Post: 07-09-2008, 07:10 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks