what is the purpose of creating a temp here?
void printAcc(int identifier) {
User2 temp = um.userList[identifier];
System.out.println("=====================");
System.out.println("ID : " + temp.id);
System.out.println("=====================");
for (int i = 0; i < temp.accCnt; i++) {
System.out.println("accNumber: " + temp.acc[i].accNumber + "/ money: " + temp.acc[i].money);
}
System.out.println("=================================\n");
}
The variable can be there so you don't have to repeat the expression
um.userList[identifier]all over the method. This is helpful if you ever need to change the way this value is retrieved (e.g.userListis changed to be aListinstead of an array)If you give it a better name than
temp, e.g.useroraccountHolder, it even serves as documentation what the variable does.