can't explain NullPointerException
Posted
by John Pope
on Stack Overflow
See other posts from Stack Overflow
or by John Pope
Published on 2010-03-24T08:30:03Z
Indexed on
2010/03/24
8:33 UTC
Read the original article
Hit count: 249
java
|nullpointerexception
In the following code, i have a method to get a Vector of persons with the same zodiac sign. persoane is a Vector. I keep getting a NullPointerException at the if condition (persoane is definetly not null). I am unable to see why. Any help would be greatly appreciated
public Vector<Persoana> cautaDupaZodie(String zodie)
{
Vector<Persoana> rezultat= new Vector<Persoana>();
for(int i=0; i<persoane.size(); i++)
{
if(persoane.get(i).getData().getZodie().equals(zodie)) //the exception occurs here
{
rezultat.add(persoane.get(i));
}
}
return rezultat;
}
© Stack Overflow or respective owner