Strange behavior of a java.util.Vector
From: Konrad Den Ende (chamsterkonrad_at_bigfoot.com)
Date: 01/25/04
- Next message: Shiv: "Session data getting corrupted."
- Previous message: db: "Printing of doc files"
- Next in thread: Jan van Mansum: "Re: Strange behavior of a java.util.Vector"
- Reply: Jan van Mansum: "Re: Strange behavior of a java.util.Vector"
- Reply: chris: "Re: Strange behavior of a java.util.Vector"
- Reply: hiwa: "Re: Strange behavior of a java.util.Vector"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 25 Jan 2004 15:28:56 +0100
I'm not sure if i'm going mad or stupid but as far as i can rely
on my eyes, when i ADD an element to a Vector, it gets put on
ALL the position, instead of the last one. It's like if it rolls all
the way down the list leaving its footprints along the way.
I wrote, like:
import java.util.*;
public class Temp {
public static void main (String[] arg) {
Vector vec = new Vector ();
String[] outPutLine = new String[3];
String line;
for (int k = 0; k < 4; k++) {
for (int i = 0; i < outPutLine.length; i++)
outPutLine[i] = "S(" + i + ";" + k + ")";
vec.add (outPutLine);
System.out.println ("outPutLine " + k + " is: \t\t" + outPutLine[0] +
"\t" + outPutLine[1] + "\t" + outPutLine[2]);
System.out.println ("The result is:");
String test = "";
for (int i = 0; i < vec.size (); i++) {
for (int j = 0; j < 3; j++)
test += ((String[])vec.get (i))[j];
test += "\n";
}
System.out.println (test + "\n---------------------------------\n");
}
}
}
So, is it just me or is there funky with the output? Where did the
element S(0;0) go, for instance?!
--
Kindly
Konrad
---------------------------------------------------
May all spammers die an agonizing death; have no burial places;
their souls be chased by demons in Gehenna from one room to
another for all eternity and more.
Sleep - thing used by ineffective people
as a substitute for coffee
Ambition - a poor excuse for not having
enough sense to be lazy
---------------------------------------------------
- Next message: Shiv: "Session data getting corrupted."
- Previous message: db: "Printing of doc files"
- Next in thread: Jan van Mansum: "Re: Strange behavior of a java.util.Vector"
- Reply: Jan van Mansum: "Re: Strange behavior of a java.util.Vector"
- Reply: chris: "Re: Strange behavior of a java.util.Vector"
- Reply: hiwa: "Re: Strange behavior of a java.util.Vector"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|