Background: Hello, I bet this is pretty fundamental but I'm fairly new to Java so bare with me, please. I'm working on a java robot that copies the information from an excel file and pastes it on a program to create a username. I get everything I need from the excel file, except an ID number.
I'm trying to generate a unique numeric-only ID (So UUID won't work). It has to be 6 digits long, thus, its range is between 100,000 and 999,999. This is what I've got so far:
public void genID() {
ArrayList<Integer> casillero = new ArrayList<Integer>();
for (int i = 100000; i < 1000000; i++) {
casillero.add(new Integer(i));
} Collections.shuffle(casillero);
for (int i = 0; i < 1; i++) {
System.out.println("El nuevo ID de casillero es: I" + casillero.get(i));
}
}
This generates a 6 digit number and that's great. But how do I make sure that this number hasn't and won't be generated next time I run my java program? Thank you!
Aucun commentaire:
Enregistrer un commentaire