Take the following code snap for example:
public int demoMethod(){
SomeClass object= getItFromSomewhere();
return object.getResult();
}
also we can directly return getItFromSomewhere().getResult()
. My question is whether the definition of "object" will low down the performance? And in some case, maybe the temporary local variable is very complicated, such as
SomeClass object = otherClassObject.getMethod1().getMethod2().getMethod3().getMethod4();
return object.getMethod5();
If I don't use the temporary "object", the statement will be very difficult to read, how about you guys deal with this case?