Re: Declaring outside a loop: speed? memory?



Philipp wrote:
Just wondering, is there a speed or memory difference between the two following codes?

Funny you should ask, because it was just mentioned on Planet Classpath http://planet.classpath.org/

Local Variables in Java
http://rmathew.blogspot.com/2007/01/local-variables-in-java.html

In short, there is no difference. The JVM specification requires them to be the same, and the same bytecode is generated.

--
Ben Caradoc-Davies <ben@xxxxxxxxxxxxx>
http://wintersun.org/
Stop Labor's plan to censor the internet:
http://efa.org.au/Issues/Censor/mandatoryblocking.html
.



Relevant Pages

  • Re: Declaring outside a loop: speed? memory?
    ... Funny you should ask, because it was just mentioned on Planet Classpath http://planet.classpath.org/ ... Local Variables in Java ...
    (comp.lang.java.programmer)
  • Re: Newbie (Post#1): Help with Array of Objects
    ... In java, unlike member ... > variables, local variables are not implicitly initialized, and you cannot ... sense if you picture yourself in a war against the compiler to make your ... The code always fails at runtime. ...
    (comp.lang.java.help)
  • Re: "Staggering power of closures..."
    ... Peter Seibel wrote: ... > them and under the covers calls a constructor with the local variables ... "Low overhead" is I guess the way ... > (The nearest translation in Java would involve making count a mutable ...
    (comp.lang.lisp)
  • Using final with local variables
    ... A question for the Java gurus. ... That makes sense because the compiler is directly writing machine code ... and can make use of the hint if it wants to. ... I am talking about local variables, ...
    (comp.lang.java.programmer)
  • Re: Garbage collection problem
    ... > variable arise because Java does not actually have nested local variable ... local variables are 'slots' in the stack ... removing the reachability of references in the reused slots. ... FirstSQL/J Object/Relational DBMS ...
    (comp.lang.java.programmer)