mercredi 15 novembre 2023

Why isn't the vector print anything out? [closed]

The expected output is for the 20,000 random ints to be stored into the vector and then my the Bublesort() method in MySort will sort an print out the vector.

There are no problems with the MySort and MyVector classes just this one. I a figure out what is wrong

package lab;

import collection.MyVector;
import java.util.*;
import collection.MySort;

public class Lab5 {
    public static void test() {
        Random rand = new Random();
        rand.setSeed(20130306);
        
        MyVector testing = new MyVector();
        for(int i=0;i<20000;i++) {
            int num = rand.nextInt(100000);
            testing.append(num);
            //System.out.println(testing.elementAt(i));
        }
        long start = System.currentTimeMillis();
        MySort.bubbleSort(testing);
        System.out.println("Bubble Sort: "+testing);
        long finish = System.currentTimeMillis();
        long timeElapsed = finish - start;
        //System.out.println("The time difference is: "+timeElapsed+ " Milliseconds");
    }
}

For the vector to print out 20,000 random sorted integers




Aucun commentaire:

Enregistrer un commentaire