import java.util.Iterator;
import java.util.Vector;
public class VectorOperations {
public static void main(String args[]){
Vector vt=new Vector();
vt.add(21);
vt.add(12);
vt.add(57);
vt.add(29);
vt.add(43);
System.out.println("Vector"+vt);
//Adding elements in Vector
vt.add(2, 25);
System.out.println("Vector"+vt);
vt.addElement(23);
System.out.println("Vector"+vt);
//Vector Operations.
System.out.println("Capacity"+vt.capacity());
System.out.println("Conatains 43:"+vt.contains(43));
System.out.println("First element"+vt.firstElement());
System.out.println("Value at Index 4: "+vt.get(4));
System.out.println("Remove value at 3"+vt.remove(3));
vt.add(43);
vt.add(45);
vt.add(46);
vt.add(47);
vt.add(48);
vt.add(49);
vt.add(32);
vt.add(33);
vt.add(34);
System.out.println("Vector Elements afte insertion more than 10 elements");
Iterator it=vt.iterator();
while(it.hasNext())
System.out.print(" "+it.next());
}
}
Output:
Vector[21, 12, 25, 57, 29, 43, 23]
Capacity10
Conatains 43:true
First element21
Value at Index 4: 29
Remove value at 357
Vector Elements afte insertion more than 10 elements
21 12 25 29 43 23 43 45 46 47 48 49 32 33 34
Wow, this post is nice, my younger sister is analyzing such things, therefore I am going to tell her.
ReplyDeleteLook into my website - rolling stones songs
Do you have any video of that? I'd love to find out some additional information.
ReplyDeleteMy web-site; country flags
Hi, I do believe this is an excellent site. I stumbledupon it ;) I am going to come back yet again since
ReplyDeleteI bookmarked it. Money and freedom is the greatest way to change,
may you be rich and continue to guide other people.
Here is my webpage understanding quotes
Hi there! This post could not be written any better! Reading
ReplyDeletethrough this post reminds me of my previous
room mate! He always kept talking about this.
I will forward this write-up to him. Fairly certain he will have a good read.
Thank you for sharing!
my web-site :: william shakespeare quotes