Somehow Vector() is null when accessing it

I am trying to code something in JAVA using a Vector. Unfortunately I have run into a seemingly very simple problem that I don't understand: myVector is null somehow.

Please take a look at the classes Element and TestElement:

import java.util.Vector;

publicclass Element{

private Vector<Integer> myVector;

public Element()

{

System.out.println("Element init.");

Vector<Integer> myVector =new Vector<Integer>();

Integer myInteger =new Integer(5);

myVector.add(myInteger);

System.out.println("Added Integer(5) to myVector, size is: " + myVector.size());

}

public Integer getIntegerFromVector()

{

if(myVector !=null)

{

System.out.println("myVector != null :)");

return myVector.elementAt(0);

}

else

{

System.out.println("myVector == null :(");

returnnull;

}

}

}

publicclass TestElement{

publicstaticvoid main(String args[])

{

System.out.println("TestElement init.");

Element myElement =new Element();

System.out.println("Element contains: " + myElement.getIntegerFromVector());

}

}

I really don't know what I am doing wrong, or what I can do to fix it. Can anyone please lend a hand? Thanks in advance.

[2523 byte] By [Burcoa] at [2007-10-2 16:50:42]
# 1
You create a local variable named "myVector". Remove the type declaration of the left side of the "=" when creating the vector.
quittea at 2007-7-13 18:02:20 > top of Java-index,Java Essentials,Java Programming...
# 2
Alright, that was silly. Thank you very much.
Burcoa at 2007-7-13 18:02:20 > top of Java-index,Java Essentials,Java Programming...