File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Game Development and the fly likes Vectors within vectors Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Reply locked New topic

Vectors within vectors

Yun Lee

Joined: Mar 11, 2010
Posts: 6

I've made a vectors within vectors, and now trying to initialise it, I just can't get it to work.

The problem is in the bold part, PLEASE help me out!!


import javax.swing.*;
import java.util.Vector;

public class Teams
//instance vars
private Vector<Vector <Object>> team1;
private Vector<Vector <Object>> team2;
private Vector<Vector <Object>> team3;
private Vector<Vector <Object>> team4;

public Teams()
team1 = new Vector<Vector <Object>>();
team2 = new Vector<Vector <Object>>();
team3 = new Vector<Vector <Object>>();
team4 = new Vector<Vector <Object>>();

FileRead("team1.txt", team1);
FileRead("team2.txt", team2);
FileRead("team3.txt", team3);
FileRead("team4.txt", team4);


public void FileRead(String fileName, Vector teamVector)
// Open the file that is the first
// command line parameter
FileInputStream fstream = new FileInputStream(fileName);
// Get the object of DataInputStream
DataInputStream in = new DataInputStream(fstream);
BufferedReader br = new BufferedReader(new InputStreamReader(in));
String strLine;
//Read File Line By line
//int counter = 0;
while ((strLine = br.readLine()) != null)
Vector<Object> v = new Vector<Object>();
String[] values = strLine.split(",");
for (String str : values)
// System.out.println(str);
//Close the input stream
catch (Exception e)
//Catch exception if any
System.err.println("Error: " + e.getMessage());

public void initialiseTeams(Vector teamVector)
Vector v = teamVector.elementAt(0).clone();
Defender def1 = new Defender(int teamVector.get(1).get(0), StringteamVector.get(1).get(1), int teamVector.get(1).get(2), int teamVector.get(1).(get3), int teamVector.get(1).get(4));


Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63854

Please do not post the same question more than once.

[Asking smart questions] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Vectors within vectors
jQuery in Action, 3rd edition