Suppose I have a method in a Java class, and I don't want any subclass of that class to be able to override that method. Can I do that?
You can declare the method to be final, as in:
final
public final String getId() { ... }
For more info, see http://docs.oracle.com/javase/tutorial/java/IandI/final.html
2.1m questions
2.1m answers
60 comments
57.0k users