Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Does reuse variable make program faster or save some memories?

807580Sep 1 2010 — edited Sep 11 2010
If I have code like:
public void test(){
    Map m1 = new HashMap();
    ....
    Map m2 = new HashMap();
    ....
}
public void test(){
    Map m1 = new HashMap();
    ....
    m1 = new HashMap();
    ....
}
Does second code make program run slightly faster or save some memories?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 9 2010
Added on Sep 1 2010
40 comments
230 views