Performance issue
Accessing a variable in stack(with in a method)
Accessing an object in heap
which is more efficient?
consider
public void getValues(request)
{
Map parameterMap=request.getParameterMap();
String first=parameterMap.get("fist");
}
request-object reference not local to this method
but parameterMap is local to this method
so which is more efficient ?
(request.getParameterMap()or parameterMap.get())
These kind of questions are usually pointless. The difference (if there is any) is far to small to make any difference in almost all cases.
And if you really want to know the answer, why don't you simply test it? Write a small program that does it (both ways) and let each way run a couple of million times and look how long it takes.
in extreme cases it might matter (stack versus heap, things like that), but if you need to worry over a few microseconds difference in call times you will have been given the training to know such things already (and will almost certainly be programming in Assembler or at worst C, not