Skip to main content
The 2026 Annual Developer Survey is live— take the Survey today!

Timeline for answer to When should I use "final"? by jtyost2

Current License: CC BY-SA 2.5

Post Revisions

6 events
when toggle format what by license comment
Feb 8, 2009 at 22:04 comment added Cornelius Dol It also enforces using Math.xxx, instead of math=new Math ... math.xxx
Feb 8, 2009 at 22:04 comment added Cornelius Dol Actually, Math is final because it's a static utility class - it has no instance methods or properties. It's common to make such a class final to lock it down.
Feb 8, 2009 at 20:51 comment added Michał Tatarynowicz What you're saying is that "final" means that the particular class makes no sense to extend?
Feb 8, 2009 at 20:48 comment added MattBelanger @Pies - well, with the given example, Absolute value has one meaning and it should not be changed, even if you want it to.
Feb 8, 2009 at 20:44 comment added Michał Tatarynowicz And if I did create a subclass of the Math class, I sure would like to be able to redefine what Absolute value means. Since subclassing implies you want to modify how the class works, "final" prevents subclassing, not modification as such. Why would you want to prevent that?
Feb 8, 2009 at 20:37 history answered Justin Yost CC BY-SA 2.5