Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Does using Final makes the execution of my code faster?

  1. #1
    Junior Member
    Join Date
    Jul 2019
    Thanked 0 Times in 0 Posts

    Default Does using Final makes the execution of my code faster?

    Does using Final (I know that the final keyword is used as a constant) makes the execution of my code faster?

    For example:
    int var1 = 98;
    final int var1 = 98;

    Or is there no difference?

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    On vacation
    Thanked 2,425 Times in 2,378 Posts

    Default Re: Does using Final makes the execution of my code faster?

    I've never seen any discussions on that.
    Perhaps you could write a test program and run it a few million times with timings to see what happens.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Input error. Program skips several lines of code during execution.
    By TMahoney1979 in forum File I/O & Other I/O Streams
    Replies: 1
    Last Post: September 21st, 2018, 10:52 AM
  2. Rectangle keeps getting faster
    By cs218087 in forum What's Wrong With My Code?
    Replies: 18
    Last Post: April 14th, 2014, 11:41 AM
  3. response to the execution of an commande by code java
    By ahmadi in forum Java Theory & Questions
    Replies: 3
    Last Post: June 10th, 2012, 09:58 AM
  4. [SOLVED] Adding the "final" keyword makes difference, I'm confused with the sequence flow.
    By SmokyBrain in forum Object Oriented Programming
    Replies: 2
    Last Post: April 30th, 2012, 01:50 AM
  5. final class, final <variable> or <data member>
    By chronoz13 in forum Object Oriented Programming
    Replies: 9
    Last Post: September 20th, 2009, 08:19 AM