previously used in C + +, know that it has an inline function concept, the general situation with the inline keyword decoration, in C + + definition class, the kind of writing in the class definition of the function, also by the compiler as an inline function processing.
Having said so much, I haven't said anything about inline functions. The so-called inline function refers to the function in the place where it is called directly, the compiler does not use the same as the general function, the argument stack, the return parameter out of the stack and the release of resources, which improves the program execution speed.
now it's time to speak Java, and there's a keyword final in the Java language to indicate that the function is inline, for example:
Java code
- public final void dosomething () {
- // to do something
- }
when called, the method will be used directly at the call, thus increasing the execution speed of the program. In addition, the final keyword has a role to prevent dosomething methods from being overwritten in subclasses, and if you want DoSomething to be a final act, it should be designed as final.
Inline is not necessarily good, when the method body that is specified as an inline is large, the overhead of the expansion may have exceeded the time of the normal function call, and the introduction of the inline has reduced performance because it should be prudent to select this keyword, but in later versions of the JVM the optimizations were made when the inline was processed. It determines whether the call is expanded based on the size of the method.
--------------------------------------------------------a gorgeous dividing line-------------------------------------------------------
Doug Lea's writing class library is a variety of optimization methods that will come to mind.
Java inline functions