public class AcakArray {
public static void main(String[] args) {
String m = JOptionPane.showInputDialog(“Berapa banyaknya angka yang akan diacak ? “);
int ma = Integer.parseInt(m);
int x=9;
int []acak = new int[ma];
for(int y=0;y<acak.length;y++){
acak[y]=(int)(Math.random()*x+1);
}
System.out.println(“Array sebelum diurutkan : “);
for(int y=0;y<acak.length;y++){
System.out.println(acak[y]);
}
Arrays.sort(acak);
System.out.println(“Hasil pengurutan Array : “);
for(int y=0;y<acak.length;y++){
System.out.println(acak[y]);
}
}
}

 

Berikut hasil outputnya :

array

Met Mencoba ^_^

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s