Wednesday, April 25, 2018

Vector Collection in Java

In this article I would like to demonstrate how to implement vectors a data structure which belongs to collection libraries in java. The code is very short and easy to understand I hope you will learn something in here.

I am currently accepting programming work, it project, school programming projects , thesis and capstone projects, IT consulting work and web development work kindly contact me in the following email address for further details. Thank you.

My email address are the following jakerpomperada@gmail.com and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.




Sample Program Output


Program Listing


VictorsExample.java


package victorsexample;

import java.util.*;

/**
 *
 * @author Mr. Jake R. Pomperada, MAED-IT
 * April 24, 2018  Tuesday
 */
public class VictorsExample {

    public static void main(String[] args) {

       System.out.println("Collections Vectors Example");
       System.out.println();
       System.out.println("Written By Mr. Jake R. Pomperada, MAED-IT");
       System.out.println();

       Vector <Integer> sample = new Vector<>();
       
       sample.add(10);
       sample.add(20);
       sample.add(30);
       sample.add(40);
       sample.add(50);
       sample.add(60);
       sample.add(70);
       sample.add(80);
       sample.add(90);
       sample.add(100);
       
  
       Enumeration display = sample.elements();
       
       while (display.hasMoreElements()) {
           System.out.print(" "+ display.nextElement()+"");
       }
       System.out.println("\n\n");
       System.out.println(" End of Program");
       System.out.println();
    }
}


No comments:

Post a Comment