I have Item item; which has getName() getter. I need to acces item.getName() in some loop. Is it better to call item.getName() in loop each time, or save it in additional variable and use that variable and is there difference?
For example: Item item;
String itemName=item.getName();
for(int i=0; i< itemArray.size();i++){
itemArray.get(i).setName(itemName);
}
or
for(int i=0; i< itemArray.size();i++){
itemArray.get(i).setName(item.getName());
}
getName()once, instead of callinggetName()each iteration. Altho finetuning like this is not anyting that would be noticable from the user point of view