vendredi 12 mars 2021

Unable to run code for creating list of random numbers [duplicate]

This is the code I'm using.

import java.util.ArrayList; public class Random {

public static ArrayList<Integer> generateRandomList( int size, int min, int max) {
    ArrayList<Integer> list;
    list = new ArrayList<>();
    for(int i=0;i<size;i++) {
        int n = (int)(Math.random() * (max-min))+min;
        list.add(n);
    }
    return list;
}

}

In Eclipse IDE when I try to run it says "the selection cannot be launched, and there are no recent launches." In Netbeans it says "no main classes found."

What am I doing wrong?




Aucun commentaire:

Enregistrer un commentaire