Share on Google+Share on Google+

Naulej kumar
Java collection Vector
1 Answer(s)      4 years and 10 months ago
Posted in : Java Beginners

How can we use the vector class in java program?

Ads

View Answers

June 21, 2012 at 5:29 PM


The vector class is similar to the ArrayList class except that the vector class is synchronized.

import java.util.Iterator;
import java.util.List;
import java.util.Vector;


public class VectorExample{
    public static void main(String [] args){
        List vector = new Vector(); 
         vector.add("Apple");
         vector.add("Orange");
         vector.add("Grapes");
         vector.add("Pine");
         vector.add( "89");
         vector.add('A');
         vector.add(25);

          vector.remove("89");
         Iterator it = vector.iterator();
         while(it.hasNext())
             System.out.println(it.next());

    }
}

Output:

Apple
Orange
Grapes
Pine
A
25

Description:- The above program demonstrates the concept of List interface. Here we have created an object of Vector class and add elements to the vector. Then we have removed an element ??89?? using remove() method from the Vector and iterated the remaining elements of vector using Iterator and display them.










Related Tutorials/Questions & Answers:
Java collection Vector
Java collection Vector  How can we use the vector class in java program?   The vector class is similar to the ArrayList class except that the vector class is synchronized. import java.util.Iterator; import
Java Vector
Java Vector       Vector represents a collection of similar items. In Java, the Vector class is defined..., its items can be accessed using an integer index. Once the Vector has been
Advertisements
Vector in java
Vector in java Vector in java implements dynamic array. It is similar to array... and the increment is specified by incr. Vector(Collection c)This form will create a vector that contain the element specified in collection. Here are some
vector - Java Interview Questions
Vector Class in Java  What is a Java Vector Class?  Hi friend,Read for more information,http://www.roseindia.net/java/beginners/vectordemo.shtml
Vector in Java
Vector in Java are array lists that are used instead of arrays, as they have... is how to declare a Vector in Java Program: This Syntax is used to declare an empty.... Vector java Example: package Toturial; import java.util.Iterator; import
vector prblem - Java Beginners
vector prblem  a java program that will accept a shopping list of 5...; static Vector list = null; static Scanner sc = new Scanner(System.in); public...: "); list = new Vector(count); while(moreNumbers && index <=count){ list.add
VECTOR - Java Interview Questions
VECTOR  How to write our own vector i want source code?  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/vectordemo.shtml Hope that it will be helpful for you. Thanks
vector object - Java Beginners
vector object  hi i have created a Vector vec=new Vector(); vec.addElement(o); o is an object of group(acl.group) what i have to do to read contents of this object? can it be possible to convert it into string arrays
vector - Java Beginners
vector  is it possible to identify the size of the vector by using length,length()  Why u want to use length and length()? Size method is there to find number of elements in vector
Java Vector
Java Vector In this tutorial, you will learn about vector and its' implementation with example. Vector is alike to ArrayList , it is also dynamic... the element of passed collection as argument. Syntax is given below : Vector
What is a vector in Java? Explain with example.
What is a vector in Java? Explain with example.  What is a vector in Java? Explain with example.   Hi, The Vector is a collect of Object... related to Vector in Java program
Java Collection
Java Collection  What are Vector, Hashtable, LinkedList and Enumeration
Java Vector
Java Vector      ... in this vector. Understand Vector by Example- This java example shows us to find a maximum element of Java Vector using max method of Collections class
Java Collection
Java Collection  What is the Collection interface
Java collection
Java collection  What are differences between Enumeration, ArrayList, Hashtable and Collections and Collection
Collection in java
Collection in java  What are the meaning of the letters E,T,K and V that come in the collection concept
arraylist vs vector - Java Beginners
arraylist vs vector  hi, i want to know what is the difference between arraylist and vector in case of performance. in what cases we should go for arraylist and in what case we should go for vector. is there any   array
Vector Iterator Java Example
Vector is a collection class.It works similar to the Array. It has... interface can traverse all its elements. Java Vector Iterator with Example import java.util.Iterator; import java.util.Vector; public class vector
Java Vector Iterator
Java Vector Iterator is a Collection class. It has similar functionality... all its elements. Java Vector Iterator Example import java.util.Iterator...(String[] args) { Vector v = new Vector(); String tree[] = { "olive", "oak
Java collection
Java collection  What is relation between map and set
Java collection
Java collection  What are differences between Enumeration, ArrayList, Hashtable and Collections
How to Define Vector Iterator in Java Program
How to Define Vector Iterator in Java Program  Hi, I want to develop a small application where i want to define vector iterator in my Java Programming. Kindly Suggest any online reference for references. Thanks
java collection
java collection  how do I use a treeset to print unique words
Java garbage collection
Java garbage collection  What is Garbage Collection and how to call it explicitly
vector question
vector question  how does vector works?   Please visit the following link: Java Vector Demo
Java : Vector Example
Java : Vector Example This segment of tutorial illustrates about the Vector class and its use with the Iterator interface. Java Vector : Vector class... it different to it as -Vector is synchronized and it contain many methods
Collection classes in java
is the reason using java collection classes saved/stored the data/content.I don't understand, what is the idea using java collection classes in project. Or the data is stored in both database and java collection classes
Collection classes in java
is the reason using java collection classes saved/stored the data/content.I don't understand, what is the idea using java collection classes in project. Or the data is stored in both database and java collection classes
what is diference between the vector and arraylist with realtime example - Java Interview Questions
what is diference between the vector and arraylist with realtime example  what is diference between the vector and arraylist with realtime example  Hi Friend, Difference between Vector and ArrayList: 1)Vector
collection
, Hashtable and Collections and Collection?   Enumeration : It is series of elements. It can be use to enumerate through the elements of a vector, keys... : It is re-sizable array implementation. Belongs to 'List' group in collection
Java collection -Hashtable
Java collection -Hashtable   What is Hashtable in java collection?   Java collection -Hashtable;- The hashtable is used to store value in the form of map key with value. import java.util.Hashtable; import
Tutorials   
Java Spring Hibernate Struts Training Retrieve database from the table dynamically in jsp from oracle using servlet What does core Java include? java What are some way to learn Java quickly? Is it required to learn Java before learning Java Script? Is it necessary to learn java script before learning PHP? Are HTML5 and Java Script boosts Java career? Is Java object oriented? Fingerprint application with Java Uninstall Oracle Virtual Box JSON to HashMap Free Java online Training I want example of Control Statement in Java ANSI Color Codes with Python Create a Program that Calculates Input What is difference between JDK,JRE and JVM? How to see ubuntu version on server? How to get Page Source in Selenium (WebDriver) using Java? The path to the driver executable must be set by the webdriver.gecko.driver system property parse data from a link in java Java Program Qns using BlueJ How to fix HAX Kernel Module Is Not Installed error? Installing Audacity Looking for code Logic to check track changes & Coments in MSWord, MSWordx, MSExcel, MSExcelx is ON/OFF Installing JDK on Mac SAX Parser exception ERROR 601 (42P00): Syntax error. Encountered Thread java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileItemFactory How to install Ubuntu 16.04 LTS? HttpServletRequest cannot be resolved to a type in eclipse - Solved Unhandled event loop exception GC overhead limit exceeded Spring Data jpa with apache phoenix Caused by: java.lang.IllegalArgumentException: Not a host:port pair: PBUF o.a.h.h.z.RecoverableZooKeeper - Possibly transient ZooKeeper, quorum= com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager class not found com.thinkaurelius.titan.diskstorage.hbase.HBaseStoreManager not found How to download and install Java 8 on Windows? How to uninstall JDK 7? How to install gtk-doc-tools package in Ubuntu? How to install Oracle JDK 8 on Ubuntu? ejabberd_ctl.beam not found - Solved How to convert date to UTC format in Java? How to install autoconf, automake and libtool in Ubuntu 15.10? How to convert current date to mm dd yyyy format in Java? How to convert current date to dd mm yyyy format in Java? How to stop window closing in "internalFrameClosing" event. How to find list of all index in Neo4j? neo4j-server.properties file location SASLError using PLAIN: not-authorized

Ads

 
Advertisement null

Ads