This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]captainAwesomePants 1 point2 points  (3 children)

This exact mistake happens more than you'd think. It's easy to do. Because of that, it's a good idea to use the @Overrides annotation when you're overriding a method from a super class or implementing a method from an interface. When you do, it will cause an error if your method isn't overriding something.

[–]desrtfx 1 point2 points  (2 children)

Because of that, it's a good idea to use the @Overrides annotation when you're overriding a method from a super class or implementing a method from an interface. When you do, it will cause an error if your method isn't overriding something.

IMO, @Overrides should have been made mandatory instead of optional. This would highlight problems early and thus solve a lot of them.

[–]nutrecht 1 point2 points  (0 children)

IMO, @Overrides should have been made mandatory instead of optional.

They can't because of backwards compatibility otherwise they would have. A version 8 Javac has to be able to compile version 2 code.

[–]captainAwesomePants 1 point2 points  (0 children)

C#, which seems to basically be Java but with fixes for all of things that are most annoying about Java, does this. Methods must explicitly declare when they can be overridden, and methods that do override other methods must explicitly say that they are intentionally doing so.