I am very new to programing. The following project I do for my programming courses at university. We have code a mini bank program where each customer should get an ID like "KU345-32". I generate these IDs with following code:
int customerID = ThreadLocalRandom.current().nextInt(1, 100000);
char firstChar = (char)ThreadLocalRandom.current().nextInt(65, 91);
char secondChar = (char)ThreadLocalRandom.current().nextInt(65, 91);
custID= "" + firstChar + secondChar + (formatCID.format(customerID)).substring(0, 3) + "-" + (formatCID.format(customerID)).substring(3, 5);
One task of this bankprogram is to sort these IDs first alphabatically then numeric:
AT234-12
BA123-08
and so on. But how is this possible? It is no problem for me to delete the - everywhere but then I dont know how to compare or which interface to use. Write an own comparable is maybe too much for me. I am looking forward to any help :)