vector

Hey guys how can I edit the object stored with in a vector..........
[75 byte] By [saranatora] at [2007-10-3 2:19:30]
# 1

You don't store Objects in a Vector, you store references to Objects in a Vector. So if you make a change to the Object's state via the reference you have, it's "edited".

Meaning:(code is not compiled, for illustration only)StringBuffer sb = new StringBuffer("init");

Vector v = new Vector();

v.add(sb);

// you can change sb this way, since you've a perfectly good reference to it already

sb.append(" edited");

// or, later, you could change it this way

StringBuffer buf = (StringBuffer)v.get(0);

buf.append(" edited again");

// either way works, and note you don't have to call add again

Good Luck

Lee

tsitha at 2007-7-14 19:18:24 > top of Java-index,Java Essentials,New To Java...
# 2
thanks lee.......got it
saranatora at 2007-7-14 19:18:24 > top of Java-index,Java Essentials,New To Java...