Java examples in the test vector

2010-03-22  来源:本站原创  分类:Java  人气:223 

/ **
* @ (#) VectorTest.java
*
*
* @ Author
* @ Version 1.00 2008/4/22
* You can use iterative methods, and the use of recycling methods class to access this class of data, how to determine which type of data, to find a way to learn.
* To use the mandatory data type conversion to complete the re-build, which is a good container, it will automatically increase. Size can be increased or reduced as needed
* /

import java.util.*;
public class VectorTest {

    public VectorTest() {
    }
    public static void main (String[] args)throws Exception
    {

       Vector vector1 = new Vector();
       Vector vector=vector1.getClass().newInstance();
       String s1="a";
         String s2="ab";
         String s5="abcde";
         String s3="abc";
         String s4="abcd";
       vector.add(s1);
       vector.add(s2);
       vector.add(s3);
       vector.add(s4);
       vector.add(3,s5);

    /* for(int i=0;i<vector.size();i++)
       {
        String in=(String)vector.get(i);
        System.out.println(in);
       }
       */
    Iterator it=vector.iterator();
    while(it.hasNext())
    {
        String in=(String)it.next();
        System.out.println(in);
    }
        }

}

:

If the vector data in many and very mixed, then use type casting is very cumbersome is to one by one in turn, undesirable.

相关文章
  • Java examples in the test vector 2010-03-22

    / ** * @ (#) VectorTest.java * * * @ Author * @ Version 1.00 2008/4/22 * You can use iterative methods, and the use of recycling methods class to access this class of data, how to determine which type of data, to find a way to learn. * To use the man

  • Java container classes List.ArrayList.Vector and map 2010-03-29

    ArrayList and HashMap is asynchronous, Vector and HashTable is synchronized, so Vector and HashTable are thread-safe, but ArrayList and HashMap is not thread-safe. Because the synchronous machine takes time, so the efficiency of the implementation of

  • Java Basics (data types, input vector) 2010-08-06

    package com.java; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Vector; import javax.swing.

  • flex + lcds communicate with the Java examples 2010-03-22

    1, web.xml configured lcds <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd"> <web-app&

  • java examples and relevant talks deadlock 2010-04-20

    Deadlock Deadlock is a situation where: more than one thread is blocked, one or all of them are waiting for a resource to be released. As the thread is blocked indefinitely, so programs can not properly terminated. Lead to deadlock is the source of i

  • JAVA examples of various sort 2010-09-11

    package sort; import java.util.Random; /** * Sort Test class * * Classification of sorting algorithm is as follows : 1. Insertion Sort ( Directly into the order. Binary insertion sort . Sort Hill ): 2. Exchange Sort ( Take bubble sort. Quick Sort ):

  • hide the title bar and java examples can be moved 2011-04-21

    import java.awt.event.MouseAdapter; import java.awt.event.MouseMotionListener; import java.awt.BorderLayout; import java.awt.Component; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.ev

  • Java Examples in a rewrite 2010-09-30

    class Person{ public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public Person(String name, int age) { this.name = name;

  • WebService using Java to write simple examples 2010-10-22

    Axis WebService using relatively simple preparation, to my understanding, WebService implementation code and write Java code, in fact, no difference was mainly what Java class will be published as a WebService. The following is a release from the pre

  • Email achieve successful examples of java 2010-11-06

    java examples of success achieved Email: Send Email solution to the problem encountered: A, jar jar package issue recommended package 1, using mail.jar 2, the use of javamail.jar 2, using mail.jar and javamail.jar These three ways can be successful,

  • JAVA Vector源码解析和示例代码 2015-03-14

    本文的学习方式是先对JAVA Vector有个整体认识,然后再学习它的源码,最后再通过实例来学会使用. 第1部分 Vector介绍Vector 是矢量队列,它是JDK1.0版本添加的类.继承于AbstractList,实现了List, RandomAccess, Cloneable这些接口. Vector 继承了AbstractList,实现了List:所以,它是一个队列,支持相关的添加.删除.修改.遍历等功能. Vector 实现了RandmoAccess接口,即提供了随机访问功能.Randm

  • Difference between Vector and ArrayList in java? 2012-06-02

    java.util.Vector came along with the first version of java development kit (JDK). java.util.ArrayList was introduced in java version1.2, as part of java collections framework. As per java API, in Java 2 platform v1.2,vector has been retrofitted to im

  • Java集合(五)应该弃用的Vector和Stack 2014-11-26

    第1部分 Vector介绍 Vector简介 Vector 是矢量队列,它是JDK1.0版本添加的类.继承于AbstractList,实现了List, RandomAccess, Cloneable这些接口. Vector 继承了AbstractList,实现了List:所以,它是一个队列,支持相关的添加.删除.修改.遍历等功能. Vector 实现了RandmoAccess接口,即提供了随机访问功能.RandmoAccess是java中用来被List实现,为List提供快速访问功能的.在Vec

  • Java programming should be noted on the basic optimization 2011-01-10

    From the book decryption android application development. [1] as far as possible modifiers specified in the class final. The class with the final modifier can not be derived. In the Java core API, there are many examples of final application, such as

  • dwr tutorial examples (including run error modification) 2009-07-21

    DWR (Direct Web Remoting) is a WEB framework for long-distance calls. Use of the AJAX development framework can become very simple. DWR can use the use of JavaScript on the client side of a direct call service method and returns the value of Java to

  • Java Specification Request 2009-09-24

    http://en.wikipedia.org/wiki/Java_Specification_Request Java Community Process From Wikipedia, the free encyclopedia (Redirected from Java Specification Request) Jump to: navigation, search <! - Start content -> The Java Community Process or JCP, es

  • Java site better 2009-09-28

    Java site better 2008-04-30 15:45 1. The Source for Java Technology Collaboration (JAVA development's official website) http://www.java.net/ - Foreign Languages 2. JGuru: FAQ Home Page Recommended http://www.jguru.com/faq/ - Foreign Languages 3. Deve

  • Java programmers must-read ten books programming skills (change) 2010-04-09

    Kevin Taylor of the Java books recommended books on the concurrent bookstores like I have not seen before. In the Web providing the only Java Servlet Programming debut, JSP, etc., and not mentioned it. Development tools, there is no one, it is I am a

  • java collection analysis (1) 2010-03-30

    1. java array similar to the elm in the vector, but can be expanded or reduced. Java, is the difference between vector and array: java arrays can store any type of array elements. Including the numerical class and all class types. java vector can onl

  • Java language in depth: the preparation of efficient thread-safe class 2010-04-08

    Java language in depth: the preparation of efficient thread-safe class Source: ccidnet.com Original Address: http://www.sudu.cn/info/html/edu/20080403/259009.html Java programming language to write multithreaded applications, providing powerful langu