This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Null Values? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Null Values?" Watch "Null Values?" New topic
Author

Null Values?

Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191


I keep getting a 'null value' in the allActivitiesLecturerLookupField[counter] memory locations instead of a lecturer's name. Why is this? All arrays have the correct information in them. What is wrong with my code?

[ February 07, 2006: Message edited by: Sam Bluesman ]
[ February 07, 2006: Message edited by: Sam Bluesman ]

Moosey knows best
Martin Mathis
Ranch Hand

Joined: Dec 20, 2004
Posts: 45
Have you tried using a debugger or output statements so that you can actually see how things are running? I'd assume that the if statement never evaluates to true, so you're left with the initial null values.
Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
Yes it prints out null 5 times. But i dont understand why.
Chris Allen
Ranch Hand

Joined: Feb 01, 2003
Posts: 127

Unless the two objects point to the same reference in memory, the expression will always be false and hence, never assign the value. I am guessing you want to use the .equals() method instead of == to test whether the objects are equivalent (data-wise) rather than pointing to the same reference in memory.
Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
how do i use .equals() in this context?
Sam Bluesman
Ranch Hand

Joined: Nov 21, 2004
Posts: 191
Forget the last post. Thank you very much people!
 
wood burning stoves
 
subject: Null Values?
 
Similar Threads
Array and condition problem
Overwriting arrays problem
Vectors vs Arrays
Using a while loop?
Files vs Arrays?