Vector troubles =_=
Hi, I need help please! I want to have a Vector of Vectors containing Strings like this:
public static
Vector<Vector><String>> anchorTxtPtrs = new Vector<Vector><String>> (SIZE);
Now, before I put String into the Vectors contained within the top-level Vector, obviously I need to create a Vector for each element of the outermost Vector...so, I'm doing this:
public static void initializeAnchorTxtPtrs () {
for (int i = 0; i < anchorTxtPtrs.size (); i++)
anchorTxtPtrs.elementAt (i) = new Vector<String> ();
}// end method initializeAnchorTextPtrs
Now, I'm getting the following compiler error under JDK 1.5...which shouldn't happen:
C:\Documents and Settings\Core Dumbie\Desktop\A4>javac *.java
PageRank.java:377: unexpected type
required: variable
found: value
anchorTxtPtrs.elementAt (i) = new Vector<String> ();
Help me please, I'm dying here!!!
Always a dumby,
Core Dumb
[1034 byte] By [
CoreDumba] at [2007-10-2 6:09:47]

you have to add() an element first for one... since your Vector is empty...
and second, elementAt() only returns a reference to an Object that has to be assigned to a variable so that you can use that reference as an assignment operation... of course you don' t need it if you are justs calling methods on said returned object ( reference )...
example...
import java.util.*;
public class GenVector {
public static void main(String[]xyz){
Vector<Vector><String>> vvs = new Vector<Vector><String>>(10);
// adding a Vector of Strings
vvs.add(new Vector<String>());
// this line...
vvs.elementAt(0).add("test");
/* is equivalent to
Vector<String> vec = vvs.elementAt(0);
vec.add("test");
same premise for the line below **/
System.out.println( vvs.elementAt(0).elementAt(0) );
}
}
for more information check out this link...
[url http://java.sun.com/docs/books/tutorial/collections/index.html] Sun's The Java Tutorial: Trail : Collections [/url]
- MaxxDmg...
- ' He who never sleeps... '