Content deleted Content added
m →Pointers and references: I think you mean to the right. "After" is better anyway. |
|||
Line 147:
i = 4; // Error! Cannot modify a "final" object
It must be decidable by the compilers where the variable with the <code>final</code> marker is initialized, and it must be performed only once, or the class will not compile. Unlike C++'s <code>const</code>, the Java <code>final</code> keyword only protects a variable from assignment, and does not
It is interesting to note that whereas Java's <code>final</code> and C++'s <code>const</code> keywords have the same meaning when applied with primitive variables, their meanings diverge when applied to method definitions. Java cannot simulate C++'s <code>const</code> methods. Similarly, C++ does not have any feature equivalent to Java's <code>final</code> modifier for methods, although its effect on classes can be simulated by a clever abuse of the C++ <code>friend</code> keyword.{{ref|cleverabuse}}
|