import javax.swing.JOptionPane; public class Bubblesort { public static void bubblesort(int[] feld){ //SORTIEREN for (int z=1; z<10; z++){ for (int y=0; y<9; y++){ if (feld[y]>feld[y+1]){ int platzhalter = feld[y]; feld[y] = feld[y+1]; feld[y+1] = platzhalter; } } } //AUSGEBEN for (int i=0; i<10; i++){ System.out.print(feld[i]+" "); } } public static void main(String[] args) { System.out.println("Bitte gib im Fenster der Reihe nach 10 Zahlen ein, die sortiert werden sollen!"); System.out.println(); //EINGEBEN int[] Array = new int[10]; for (int i=0; i<10; i++){ String eingabe = JOptionPane.showInputDialog("Bitte gib die "+(i+1)+". Zahl des Feldes ein: "); Array[i] = Integer.parseInt(eingabe); } System.out.println("Hier sind die Zahlen - sortiert vom Bubblesort:"); bubblesort(Array); } }