import java.util.LinkedList;
import java.util.Queue;
import java.util.Random;
public class TestQueueTwo {
public static void main(String[] args) {
Random random = new Random();
int counter = 0;
String color = " ";
String ticket;
int listSize = 5;
int attendants = 2;
String[] colors = {"red", "blue", "yellow"};
Queue<String> tickets = new LinkedList<>();
while(tickets.size() < listSize)
{
color = colors[random.nextInt(3)];
ticket = color + (random.nextInt(listSize) + 1);
tickets.add(ticket);
}
}
}
I am working on a college exercise in Java, and after generating these random passwords, I need to put them in a queue list, and the exercise requires using only one list.
I need to organize it so that the red passwords come first, the blue ones second, and the yellow ones third.
Example: (red1, red5, blue3, blue7, yellow8)
Which method can I use to organize this using only one list?