Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Vectors within vectors

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Hi,

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!!


thanks.


import java.io.*;
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);

initialiseTeams(team1);
}

public void FileRead(String fileName, Vector teamVector)
{
try
{
// 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>();
teamVector.addElement(v);
String[] values = strLine.split(",");
for (String str : values)
{
v.addElement(str);
// System.out.println(str);
}
v.trimToSize();
teamVector.trimToSize();
}
//Close the input stream
in.close();
}
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));


}

}
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not post the same question more than once.
 
Talk sense to a fool and he calls you foolish. -Euripides A foolish tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
    Bookmark Topic Watch Topic
  • New Topic