(4) All methods are defined in the body of the class. So in the eyes of C + +, it seems that all functions are embedded, but the truth is not how (the embedded problem is described later).
There is no "embed" (inline) method in Java. The Java compiler may decide to embed a method on its own, but we have no more control over it. In Java, you can use the final keyword for a method to "suggest" an embedding operation. However, embedding functions is also a recommendation for C + + compilers.
The Java member function, whether inline or not, is defined in the class-defined code, which is only the inline function in C + +. In Java, the final keyword is the difference between the inline and the final keyword, and you can "suggest" that the compiler embed the method. Whether or not the compiler will actually embed, depending on its judgment, the final keyword is just a suggestion for the person who wrote the program, or the compiler.
What is the operation of the embed operation.
Parameter into the stack, executing a copy of the function code. and C + + is the same
Final key word:
1. After the final keyword is added, the member function is locked and will not be overloaded in inheritance. (This is different from the "recommended" embedding operation)
2. The private member function is implied as final, of course, if willing to give private members plus final keyword is also allowed, but there will be no additional effect.
3. Because private member functions do not actually act as inherited interfaces, there is no question of how to dispose of overloaded private final functions.
4. The final keyword is added to a class, which means that the class is not allowed to be modified and inherited; With the final class, the function members are implicitly final, without having to add the final keyword to the function separately.