vector in java vector class in java vector class in java example vector class in java 6 example program for vector class in java example of vector in java vector in java api vector in java example vector in java tutorial difference between vector and arraylist difference between vector and array difference between vector and arraylist in java difference between vector and arraylist in java with example difference between vector and arraylist and linkedlist in java vector class in java api
Vector :
It is one of the
predefined 1 – D Legacy Collection frame concrete class present in
java.util.* package. The default capacity of vector class ten cells. On the default size of
vector class object is zero. No one should not think the capacity ten of Vector is not fixed
and it is can be expandable during incoming flow of data in the Vector class object.
java.util.* package. The default capacity of vector class ten cells. On the default size of
vector class object is zero. No one should not think the capacity ten of Vector is not fixed
and it is can be expandable during incoming flow of data in the Vector class object.
The functionality of vector class object is more or less similar to ArrayList class. But
vector object class belongs to synchronized and ArrayList class object belongs to non –
synchronized.
Vector class object always organizes the data in the form of cells. Internally all the values
of vectors are processed based on Zero – based indexing concept.
Profile of Vector Class :
Constructors :
1) Vector()
2)
Vector(int)
Instance Methods :
3) Public void addElement(Object)
4)
Public void addElement(int,Object)
5)
Public void removeElement(Object)
6)
Public void removeElementAt(int)
7)
Pubic Object getElement(int)
8)
Public int capacity()
9)
Public int size()
10)
Public Enumeration elements()
From the above profile i.e constructors and instance methods.
In constructors first constructor is used for creating the object of
vector class, and second constructor is used for creating object and by
specifying number of cells or size.
All the instance methods from 3 to 6 is used for adding and removing
elements.
One
important methods among all methods is elements.
Public Enumeration elements() :
This method is used for retrieving or extracting all the elements of any
legacy
collection frame work and forms like a chain and this method returns any object of
Enumeration and it is by default pointing just before the first element.
ArrayList Vs Vector class :
collection frame work and forms like a chain and this method returns any object of
Enumeration and it is by default pointing just before the first element.
ArrayList Vs Vector class :
The functionality of vector class object is more or less similar to ArrayList class. But vector object class belongs to synchronized and ArrayList class object belongs to non – synchronized.
The Following
Example Illustrate the Concept of Vector Class :
import java.util.*;
Class vect
{
Public static
void main(String Args[])
{
Vector v=new
Vector();
System.out.println(“Content of v”+v);
System.out.println(“Size of v “+v.size());//0
System.out.println(“Capacity of v “+v.capacity());//10
//add the data to vector.
v.add(new
Integer(10));
v.add(new
Float(20.3f));
v.add(new
Character(‘a’));
v.add(new String(“JavaJavax”));
System.out.println(“Content of v”+v);//10, 20.3,
a, JavaJavax
System.out.println(“Size of v “+v.size());//4
System.out.println(“Capacity of v “+v.capacity());//10
System.out.println(“Extract the data from
vector”);
Enumeration
e=v.elements();
While(e.hasMoreElements())
{
Object
obj=e.nextElement();
System.out.println(obj);
}
}
}
}
Data Extraction Interfaces are as follows :
1- D and 2-D Collection Frame work classes are
No comments:
Post a Comment