Eclipse Java: Kleinste Zahl ausgeben

3 Antworten

Vom Fragesteller als hilfreich ausgezeichnet

import java.util.Random;

public class Zufallszahlen {

private static int [] array = new int [10];
private static Random zufallszahlengenerator = new Random();
private static int hilfe = 100;

public static void main(String [] args)
{
    for(int i = 0; i<array.length; i++)
    {
        array[i] = 1+zufallszahlengenerator.nextInt(100);
    }

    for(int i = 0; i<array.length; i++)
    {
        if(array[i]<hilfe)
        {
            hilfe = array[i];
        }
    }

    System.out.println("Die kleinste aus 10 Zufallszahlen ist: " + hilfe);

}

}

Ganz einfach: erstmal Programmieren lernen

Bei 0 wird hier niemand mit dir anfangen und dir fertigen Quelltext vor die Füße tragen.

Hikaru755  09.02.2011, 16:23

Tja, wohl doch... :D

0

Schau dich mal in der API nach java.lang.math um...