# My vector code

• 01-29-2012, 11:47 PM
drico7041
My vector code
How do I make my code count the amount of 1's, 2's, 3's ... 98's and 99's in the vector. I'm having trouble completing this. Please help.
Code:

``` import java.util.*; import java.util.Vector; import java.util.Random; import javax.swing.JOptionPane; import java.util.Collections; import java.util.List; public class Count {     public static void main(String[] arg) {         String output;         int[] anArray = new int [100];         int a;         Vector<Integer> vect = new Vector<Integer>(1,10000);         {             Random generator = new Random();             for (int i = 1; i < 10000; i++) {                 int rand = generator.nextInt(97);                 vect.add(rand);                 vect.add(Math.abs(generator.nextInt()) % 99);             }             //you can only sort it after you generated the random numbers             Collections.sort(vect);             for (int i = 1; i < vect.size(); i++) {                 System.out.println(vect.get(i)+ 1);                           }     }     } }```
• 01-30-2012, 12:04 AM
diamonddragon
Re: My vector code
Just to inform that Vector class is predecessor of ArrayList class.
• 01-30-2012, 01:00 AM
drico7041
Re: My vector code
I know. But unfortunately my teacher is making me use vectors..