core Java Collections

core Java Collections

View Answers

September 14, 2009 at 1:52 PM

Hi Friend,

The Vector implements a growable array of objects. It contains components that can be accessed using an integer index like an array. The size of a Vector can grow or shrink as needed to accommodate adding and removing items in vector.

Example:

import java.util.*;
public class VectorDemo{
public static void main(String[] args){
Vector<Object> vector = new Vector<Object>();
int primitiveType = 10;
Integer wrapperType = new Integer(20);
String str = "tapan joshi";
vector.add(primitiveType);
vector.add(wrapperType);
vector.add(str);
vector.add(2, new Integer(30));
System.out.println("the elements of vector: " + vector);
System.out.println("The size of vector are: " + vector.size());
System.out.println("The elements at position 2 is: " + vector.elementAt(2));
System.out.println("The first element of vector is: " + vector.firstElement());
System.out.println("The last element of vector is: " + vector.lastElement());
vector.removeElementAt(2);
Enumeration e=vector.elements();
System.out.println("The elements of vector: " + vector);
while(e.hasMoreElements()){
System.out.println("The elements are: " + e.nextElement());
}
}
}

Difference between Array and Vector:

1.Vector is implemented from List interface where as array is a primitive
2.The size of a vector can be changed dynamically where as size is fixed in array.
3.Vector is Synchronized where as array is not
4.Vector can store only object references where as Array can store primitive data type.

Thanks









Related Tutorials/Questions & Answers:
core Java Collections - Java Beginners
core Java Collections   what is Vector? send me any example what is differece between Array and Vector? Why Vector is called Sychronized?  Hi Friend, The Vector implements a growable array of objects
java collections
java collections  what are all the methods and things added for collections in java5 and java6 please kindly reply me as soon as possible
Advertisements
Collections in Java
Collections in Java  What is Concurrent Hash map
Collections in Java
Collections in Java  What is Concurrent Hash map
java collections
java collections  Dear Friends plz help me to complete this program import java.util.*; public class StringDemo { static String a="{a=100;b=200;c=300... achieve this plz without using stringtokenizer with any collections!!!  
collections in java
collections in java  please explain me the flow of this program..i m getting o/p as 2 1 1..y not 2 1 0..is it that if we change the i2 value,it doesnt remove. import java.util.*; public class Mapit { public static void main
Collections
/java/jdk6/introduction-collections-api.shtml http://www.roseindia.net/javacodeexamples/index.shtml http://www.devmanuals.com/tutorials/java/collections/index.html...Collections  Hi, Please send a study material on collections
collections - Java Interview Questions
collections  The Java Collections API  Hi friend, Java Collections of API (Application Programming Intreface) Consists of several... information on Java Collection API visit to : http://www.roseindia.net
wt are the collections in java
wt are the collections in java  plese send me the reply   Hi Friend, Java Collections API (Application Programming Interface) Consists... information on Java Collection API visit to : Collection API Thanks
collections - Java Interview Questions
collections   what is the way to insert map values into a set in collections
java Collections - Java Beginners
java Collections   HI Friends, I want to pick a random element from a set.How can i achieve this.I have a set of objects , I want to pick a random object every time from the set..  Hi Friend, Try
collections in java - Java Interview Questions
collections in java  What is collection
collections
collections  in collections can we perform binarysearch on arraylist elements without sorting them
collections
collections  why we need collections.when we will use collections in our applications
java collections - Java Beginners
java collections  i need a sample quiz program by using collections and its property reply soon as possible ....   Hi Friend, Try the following code: import java.io.*; import java.util.*; class Test { String
Collections - Java Beginners
Collections  I want to know about the new for loop used in collections... can anyone explain in short..? If possible can you give some sites..., http://www.roseindia.net/java/jdk6/introduction-collections-api.shtml
collections - Java Interview Questions
in Array of type Integer. Collections : ArrayList al = new ArrayList
Collections in Java
Collections in Java are data-structures primarily defined through a set of classes and interface and used by Java professionals. Some collections in Java that are defined in Java collection framework are: Vectors, ArrayList, HashMap
java collections - Java Beginners
java collections  Object o1=new Object("hello"); Object o2=new Object("hello"); is hashmap add these objects?  Hi Friend, The constructor of Object class doesn't contains any parameter. IF you want to any object
Collections arraylist - Java Interview Questions
Collections arraylist  how we can make array list as syncronised....and what will be the code for that?  Hi Friend, Try the following code: import java.util.*; class SynchronizedArrayList{ public static void
Maven dependency for commons-collections - commons-collections version 3.0 is released. Learn to use commons-collections version 3.0 in Maven based Java projects
-collections version 3.0 ) in their Java project if it is based on Maven...-collections - commons-collections version 3.0 java library in your project. ADS...-collections released The developers of   commons-collections
Maven dependency for commons-collections - commons-collections version 2.0 is released. Learn to use commons-collections version 2.0 in Maven based Java projects
-collections version 2.0 ) in their Java project if it is based on Maven...-collections - commons-collections version 2.0 java library in your project. ADS...-collections released The developers of   commons-collections
Java Collections - Java Interview Questions
Java Collections  Hi, can anybody tell me, Using which collection we can get the data of an employee from the Emp table when the value of the column... to : http://roseindia.net/java/collection/collection-get-column.shtml Thanks
Maven dependency for commons-collections - commons-collections-testframework version 3.0 is released. Learn to use commons-collections-testframework version 3.0 in Maven based Java projects
-collections-testframework released The developers of   commons-collections - commons-collections-testframework project have released the latest...-collections - commons-collections-testframework library is 3.0. Developer can use
Maven dependency for net.sf.kerner-utils-collections - kerner-utils-collections version 1.1.1 is released. Learn to use kerner-utils-collections version 1.1.1 in Maven based Java projects
-collections version 1.1.1 ) in their Java project if it is based on Maven and Gradle... - kerner-utils-collections version 1.1.1 in Java projects. Follow the step by step...; net.sf.kerner-utils-collections - kerner-utils-collections version 1.1.1 java
Maven dependency for net.sf.kerner-utils-collections - kerner-utils-collections version 0.24.0 is released. Learn to use kerner-utils-collections version 0.24.0 in Maven based Java projects
-collections version 0.24.0 ) in their Java project if it is based on Maven... - kerner-utils-collections version 0.24.0 in Java projects. Follow the step... 0.24.0 of kerner-utils-collections released The developers of  
Maven dependency for net.sf.kerner-utils-collections - kerner-utils-collections version 0.22.2 is released. Learn to use kerner-utils-collections version 0.22.2 in Maven based Java projects
-collections version 0.22.2 ) in their Java project if it is based on Maven... - kerner-utils-collections version 0.22.2 in Java projects. Follow the step... 0.22.2 of kerner-utils-collections released The developers of  
Maven dependency for net.sf.kerner-utils-collections - kerner-utils-collections version 0.5.0 is released. Learn to use kerner-utils-collections version 0.5.0 in Maven based Java projects
-collections version 0.5.0 ) in their Java project if it is based on Maven and Gradle... - kerner-utils-collections version 0.5.0 in Java projects. Follow the step by step...; net.sf.kerner-utils-collections - kerner-utils-collections version 0.5.0 java
Maven dependency for net.sf.kerner-utils-collections - kerner-utils-collections version 0.1.1 is released. Learn to use kerner-utils-collections version 0.1.1 in Maven based Java projects
-collections version 0.1.1 ) in their Java project if it is based on Maven and Gradle... - kerner-utils-collections version 0.1.1 in Java projects. Follow the step by step...; net.sf.kerner-utils-collections - kerner-utils-collections version 0.1.1 java
what is collections?
what is collections?  what is collections
Collections API
Collections API  hello, What is the Collections API?   hiADS_TO_REPLACE_1 The Collections API is a set of classes and interfaces that support operations on collections of objects
Maven dependency for com.facebook.jcommon - collections version 0.1.3 is released. Learn to use collections version 0.1.3 in Maven based Java projects
; com.facebook.jcommon - collections version 0.1.3 in Java projects. Follow... and includes  com.facebook.jcommon - collections version 0.1.3 java library... of collections released The developers of   com.facebook.jcommon
Maven dependency for net.openhft - collections version 3.0d is released. Learn to use collections version 3.0d in Maven based Java projects
this version ( net.openhft - collections version 3.0d ) in their Java project... in project? Steps to use  net.openhft - collections version 3.0d in Java...; net.openhft - collections version 3.0d java library in your project. ADS
Maven dependency for net.openhft - collections version 3.0a is released. Learn to use collections version 3.0a in Maven based Java projects
this version ( net.openhft - collections version 3.0a ) in their Java project... in project? Steps to use  net.openhft - collections version 3.0a in Java...; net.openhft - collections version 3.0a java library in your project. ADS
Maven dependency for com.twineworks - collections version 1.2.1 is released. Learn to use collections version 1.2.1 in Maven based Java projects
this version ( com.twineworks - collections version 1.2.1 ) in their Java...Maven dependency for  com.twineworks  - Version 1.2.1 of collections released The developers of   com.twineworks - collections project
Maven dependency for com.twineworks - collections version 1.2.0 is released. Learn to use collections version 1.2.0 in Maven based Java projects
this version ( com.twineworks - collections version 1.2.0 ) in their Java...Maven dependency for  com.twineworks  - Version 1.2.0 of collections released The developers of   com.twineworks - collections project
Maven dependency for com.jonlandrum - collections version 1.0 is released. Learn to use collections version 1.0 in Maven based Java projects
this version ( com.jonlandrum - collections version 1.0 ) in their Java project... and includes  com.jonlandrum - collections version 1.0 java library...Maven dependency for  com.jonlandrum  - Version 1.0 of collections
Maven dependency for com.facebook.jcommon - collections version 0.1.26 is released. Learn to use collections version 0.1.26 in Maven based Java projects
to use  com.facebook.jcommon - collections version 0.1.26 in Java projects. Follow... that downloads and includes  com.facebook.jcommon - collections version 0.1.26 java... of collections released The developers of   com.facebook.jcommon
Maven dependency for br.com.objectos.core - collections version 0.2.0 is released. Learn to use collections version 0.2.0 in Maven based Java projects
to use  br.com.objectos.core - collections version 0.2.0 in Java projects... - collections version 0.2.0 java library in your project. ADS_TO_REPLACE_2 Now you... of collections released The developers of   br.com.objectos.core
Maven dependency for com.facebook.jcommon - collections version 0.1.27 is released. Learn to use collections version 0.1.27 in Maven based Java projects
to use  com.facebook.jcommon - collections version 0.1.27 in Java... - collections version 0.1.27 java library in your project. ADS_TO_REPLACE_2... of collections released The developers of   com.facebook.jcommon
Maven dependency for br.com.objectos - collections version 0.1.0 is released. Learn to use collections version 0.1.0 in Maven based Java projects
- collections version 0.1.0 in Java projects. Follow the step by step tutorial...; br.com.objectos - collections version 0.1.0 java library in your project. ADS... of collections released The developers of   br.com.objectos - collections
Hibernate Criteria With Collections Example
Hibernate Criteria With Collections Example  Good code of Hibernate Criteria With Collections Example. Thanks   Example program of using Hibernate Criteria With Collections in your Java project. Check the tutorial
Java Collections - Design concepts & design patterns
Java Collections  I am designing an application where the program is meant to read from 2 different text files (eg FileA and FileB) containing so many Long numbers (e.g 4 million numbers in each file). The application is meant
Java Collections - Design concepts & design patterns
Java Collections  I am designing an application where the program is meant to read from 2 different text files (eg FileA and FileB) containing so many Long numbers (e.g 4 million numbers in each file). The application is meant
Working with java Collections class
Working with java Collections class   ... with Collections class of java.util package. Actually java collections framework... of Collections class. For example- add element, copy elements, reverse data
Maven dependency for com.facebook.jcommon - collections-foundation version 0.1.17 is released. Learn to use collections-foundation version 0.1.17 in Maven based Java projects
( com.facebook.jcommon - collections-foundation version 0.1.17 ) in their Java project... - collections-foundation version 0.1.17 in Java projects. Follow the step... of collections-foundation released The developers of   com.facebook.jcommon
Maven dependency for com.facebook.jcommon - collections-foundation version 0.1.13 is released. Learn to use collections-foundation version 0.1.13 in Maven based Java projects
( com.facebook.jcommon - collections-foundation version 0.1.13 ) in their Java project... - collections-foundation version 0.1.13 in Java projects. Follow the step... of collections-foundation released The developers of   com.facebook.jcommon
Maven dependency for org.swimos - swim-collections version 4.0.0 is released. Learn to use swim-collections version 4.0.0 in Maven based Java projects
use this version ( org.swimos - swim-collections version 4.0.0 ) in their Java...-collections version 4.0.0 in Java projects. Follow the step by step tutorial...-collections released The developers of   org.swimos - swim-collections project
Maven dependency for systems.manifold - manifold-collections version 2022.1.27 is released. Learn to use manifold-collections version 2022.1.27 in Maven based Java projects
- manifold-collections version 2022.1.27 ) in their Java project if it is based...-collections version 2022.1.27 in Java projects. Follow the step by step tutorial... and includes  systems.manifold - manifold-collections version 2022.1.27 java library
Maven dependency for systems.manifold - manifold-collections version 2022.1.27 is released. Learn to use manifold-collections version 2022.1.27 in Maven based Java projects
- manifold-collections version 2022.1.27 ) in their Java project if it is based...-collections version 2022.1.27 in Java projects. Follow the step by step tutorial... and includes  systems.manifold - manifold-collections version 2022.1.27 java library

Ads