r/programming • u/[deleted] • Aug 11 '15
Top 10 Useful, Yet Paranoid Java Programming Techniques
http://blog.jooq.org/2015/08/11/top-10-useful-yet-paranoid-java-programming-techniques/
28
Upvotes
r/programming • u/[deleted] • Aug 11 '15
4
u/sh0rug0ru___ Aug 11 '15 edited Aug 11 '15
<pendantry>
All non-static methods are virtual in Java. Regardless of the pointer you have to the object (whether it is the concrete type or a super type), the same method will be called. Always.
On the other hand in C#, instance methods are by default non-virtual and cannot be overridden. But, that does not mean they cannot be overloaded. Thus, a pointer of the concrete type and a pointer of a super type can actually invoke different methods!
The equivalent to Java's
finalin C# is actuallysealed. Which is not the default!</pedantry>