Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- import java.util.Random;
- /**
- *
- * @author WIF170039
- */
- public class L5Q2 {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // TODO code application logic here
- int [] num = new int [10];
- int number;
- Random rand = new Random ();
- System.out.println("The random integers are :");
- for (int i=0; i<10; i++) { //for (int i=0; i<number.length; i++) number.length is #of array
- num [i] = rand.nextInt(21);
- for (int j=0; j<i; j++) {
- if (num[i]==num[j]) {
- i--;
- break; //teruskan compare
- /*
- if (num[i]!=num[j]) {
- continue; *teruskan compare*
- }
- else {
- i--;
- break;
- }
- */
- }
- }
- }
- for (int i=0; i<10; i++) {
- System.out.print(num[i] + " " );
- }
- }
- }
Add Comment
Please, Sign In to add comment