Java: Efficiency cost of new object to store field vs object access -


i produced code

for(string buff : arrays.aslist(         formula_pattern.matcher(s).group().split("\n")         ) 

and started wondering performance lies not creating explicit local container method returns. (also, i'm not sure works, i'm prototyping stuff while waiting full specs)

related java coding style, local variables vs repeated method calls i'm curious of actuality of it.

for coding pattern (not specific case, examples)

integer.parseint(buff.substring(buff.length()-1)); 

is there gain/loss over

int x = buff.length() -1; integer.parseint(buff.substring(x); 

or, more general case of language, avoiding primitives

integer x = buff.length() -1; integer.parseint(buff.substring(x); 

this may differ collections, curiosity cost associated java's pass value having cost instantiate object returned.

not concerned readability, wondering if, when, , how 1 method outperform other.


Comments