Here's the code I have that solves my problem. But it seems really brute forced. Is there any optimized/elegant way to write this?
System.out.println("\n\nPart II: Let' put in a list of 50 random numbers between 10 to 99. No Duplicates!");
Linkedlist l1 = new Linkedlist();
Random rand = new Random();
for(int i = 0; i < 50; i++){
int num = rand.nextInt(89) + 10;//range between 10 and 99.
while(true){
if(!l1.search(num)){
l1.add(num);
break;
}
else
num = rand.nextInt(89) + 10;//recycle for new num
}//infinite loop until new non-duplicate random value is generated for the list.
}//for