Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Vector element nulls

Status
Not open for further replies.

timmbo

Programmer
Joined
Feb 22, 2001
Messages
167
Location
US
Hi All,

How would I check a vector that has (some) null elements. My vector is returning the information I need. If the element is null, I have to do some specific coding. My current code is returning "Invalid left hand side of assignment." error.
So, how would I check this?

My current code is:


Code:
...
for(int i = 0;accounts.size()>1;i++) {
   String acct = (String)accounts.elementAt(i);
   System.out.println("One");
   System.out.println("acct... " + acct);
   Vector tmpRecs = (Vector)wires.get(acct);
   System.out.println("Two");
   System.out.println(tmpRecs);	
   System.out.println("Three");
   if(tmpRecs.elementAt(i) = null) {<----- error...
      System.out.println(&quot;Four (null)...&quot;);
   }
}
...

If you need to see a bigger picture of my code, please let me know.

TIA,
Tim
 
You need to use == (double equal sign) when comparing an object to null.
 
Thanks for the quick reply. I totally missed that...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top