September 07, 2010, 04:51:14 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  Home Help Media Affiliates Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Vector tutorial  (Read 886 times)
0 Members and 1 Guest are viewing this topic.
Arkie
Javaforums.net Admin
Senior Member
*

Reputation: 16
Developer @ Javaforums.net
Offline Offline
Posts: 2620
Referrals: 13

WWW Awards
« on: June 08, 2007, 12:08:38 PM »

This demo will show you how to add elements in the Vector


Code
GeSHi (java):
  1. mport java.util.Vector;
  2.  
  3. public class VectorTest {
  4. static Vector v = new Vector();
  5.  
  6.  
  7. public static void main(String[] args) {
  8.  
  9. for (int i = 0; i < 10; i++) {
  10. int randomNumber =  (int) (( 1+ (Math.random() * 10)));
  11. v.add(randomNumber);
  12. }
  13. v.add("Random");
  14. v.add("Text");
  15. System.out.println("Vector contains: " + v);
  16. }
  17.  
  18. }
Created by GeSHI 1.0.7.20


Output:
Vector contains: [8, 6, 1, 5, 5, 7, 2, 5, 5, 2, Random, Text]
Logged

Java and .NET developer

To students: It doesn't matter how hard you've studied; the material won't be on the exam anyway.

Fan of http://www.retardedweblogger.com
Oh man, too much stuff to do in so little time.

http://img222.imageshack....707/arkietomatoesmall.jpg
Blizzcon 2k9 Grubby and Cassandra Ng engaged ! <3
Triple D, eerste Denken Dan Doen
Javaforums.net :: a community about Java software development.
« on: June 08, 2007, 12:08:38 PM »

Your Ad Here
 Logged
Pages: [1]   Go Up
  Print  
 
Jump to:  

Your Ad Here
Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC
TinyPortal v0.9.8 © Bloc
Valid XHTML 1.0! Valid CSS!
Page created in 0.186 seconds with 32 queries.

Google visited last this page September 05, 2010, 10:43:59 AM