PROGRAM FOR ENTERING DIFFERENT OBJECTS INTO VECTOR

import java.util.*; class vect {             public static void main(String args[])             {                               ...

import java.util.*;
class vect
{
            public static void main(String args[])
            {
                                   Vector v=new Vector(6);
                                   System.out.println("SIZE IS"+v.size());
                                   System.out.println("CAPACITY IS"+v.capacity());
                                   v.addElement(new Integer(3));
                                   v.addElement(new Integer(8));
                                   v.addElement(new Integer(10));
                                   v.addElement("boss");
 System.out.println("AFTER INSERTING  VECTORSIZE"+v.size());
 v.addElement(new Float(5.8));
 System.out.println("LAST ELEMENT IS"+v.lastElement());
 System.out.println("FIRST ELEMENT IS"+v.firstElement());
                                  Enumeration e=v.elements();
                                  System.out.println("ELEMENTS IN  VECTOR");
                                  while(e.hasMoreElements())
                                                {
                                                         System.out.println(e.nextElement());
                                                }                      
            }
}


OUTPUT:

SIZE IS 0  CAPACITY IS 6
AFTER INSERTING VECTORSIZE 4
LAST ELEMENT IS 5.8
FIRST ELEMENT IS 3
ELEMENTS IN  VECTOR     3
8
10
boss

5.8

Related

What are Mathematical Functions in Java?

Java supports basic mathematical functions through math class defined in the Java long package. These functions should be used as follows math. Function _ name( ); Example: Double y = math. S...

Why is Java known as Plat Form Neutral Language?

The goal of Java is “write once run anywhere, any time, forever”. So Java is not dependent on any platform. It creates byte code, this code supports to all platforms. So Java is known as p...

How is Java more Secured than Other Languages?

Everything that you download form internet, you are risking a viral infection. Prior to Java, most users did not download executable programs frequently, and those who did scan them for virus prior ...

Post a Comment

emo-but-icon
:noprob:
:smile:
:shy:
:trope:
:sneered:
:happy:
:escort:
:rapt:
:love:
:heart:
:angry:
:hate:
:sad:
:sigh:
:disappointed:
:cry:
:fear:
:surprise:
:unbelieve:
:shit:
:like:
:dislike:
:clap:
:cuff:
:fist:
:ok:
:file:
:link:
:place:
:contact:

item