Is there any differences between doing
Field field = something.getSomethingElse().getField();
if (field == 0) {
//do something
}
somelist.add(field);
versus
if (something.getSomethingElse().getField() == 0) {
//do something
}
somelist.add(something.getSomethingElse().getField());
Do references to the field through getters incur a performance penalty or is it the same as referencing an assigned variable? I understand that the variable is just a reference to the memory space, so the getter should just be another way to get at that memory space.
Note that this is an academic question (school of just curious) rather then a practical one.