Essentially, is it possible to rename an array after it has been created to associate it with a unique ID (so only users with the ID can access that specific array).. This is for a restaurant owner and refrigerator program. The array is for a refrigerator which holds 3 items. The user has to input the Refrigerator ID to get access to the food items within it. I am a beginner in Java and programming in general so i have no idea what to do or what to search even.
I have created a method to generate a random string for the unique ID and i just don't know how to rename the array to that ID.
public class Refrigerators
{
public static String generateUniqueID()
{
int leftLimit = 97; // letter 'a'
int rightLimit = 122; // letter 'z'
int targetStringLength = 4;
Random random = new Random();
StringBuilder buffer = new StringBuilder(targetStringLength);
for (int i = 0; i < targetStringLength; i++)
{
int randomLimitedInt = leftLimit + (int)
(random.nextFloat() * (rightLimit - leftLimit + 1));
buffer.append((char) randomLimitedInt);
}
String generatedString = buffer.toString();
return generatedString;
}
void newFridge()
{
//add a fridge array consisting of 3 items
String ID = generateUniqueID();
String[] fridge = new String[3];
System.out.println("fridge unique ID has been created: "+ ID);
}