Vector in Java - Sample Program
By: Paawan Chaudhary Printer Friendly Format
This java program implements a Vector that accepts five items from the command line and store them in a Vector and display the objects stored in a Vector.
import java.lang.*;
import java.io.*;
import java.util.*;
class q8Vector
{
public static void main(String args[])
{
Vector list = new Vector();
int len=args.length;
for(int i=0;i<len;i++)
{
list.addElement(args[i]);
}
int size=list.size();
String str[]= new String[size];
list.copyInto(str);
for(int i=0;i<size;i++)
{
System.out.println ("Element of Vector at position "+i+":"+str[i]);
}
}
}
Comment on this tutorial
- Data Science
- Android
- AJAX
- ASP.net
- C
- C++
- C#
- Cocoa
- Cloud Computing
- HTML5
- Java
- Javascript
- JSF
- JSP
- J2ME
- Java Beans
- EJB
- JDBC
- Linux
- Mac OS X
- iPhone
- MySQL
- Office 365
- Perl
- PHP
- Python
- Ruby
- VB.net
- Hibernate
- Struts
- SAP
- Trends
- Tech Reviews
- WebServices
- XML
- Certification
- Interview
categories
Subscribe to Tutorials
Related Tutorials
Program using concept of byte long short and int in java
Update contents of a file within a jar file
Tomcat and httpd configured in port 8080 and 80
Count number of vowels, consonants and digits in a String in Java
Student marks calculation program in Java
Calculate gross salary in Java
Calculate average sale of the week in Java
Vector in Java - Sample Program
MultiLevel Inheritance sample in Java
Archived Comments
1. can you non grab the data direct from the vector w
View Tutorial By: paul at 2013-08-30 11:22:04
2. hello,
how can i add a specific variable va
View Tutorial By: Abdulla at 2014-12-05 15:30:27
3. hi!
how can i add variable form object to a
View Tutorial By: rushi at 2015-07-16 08:18:58
4. how this program is work , please, tell
View Tutorial By: rohit kumar at 2015-10-30 12:22:05
5. can you please help me with the code for storing t
View Tutorial By: roja at 2016-02-04 08:03:49
6. Major thanks for the blog post. Really Great.
View Tutorial By: Latest Happy Holi Wishes at 2016-02-12 10:10:53
7. I truly appreciate this blog post.Really looking f
View Tutorial By: CBSE 10th Result at 2016-02-12 10:30:52
8. It's a shawme you don't have a donate button! I'd
View Tutorial By: Barcelona Strip club at 2017-03-04 09:33:31