• Post Reply Bookmark Topic Watch Topic
  • New Topic

@override in j2se 5  RSS feed

 
Tian Zhang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

just a quick question: i am using jdk 1.5.(something) with intelliJ 4.5, and when override a method i get a intensions tip to change to @Override. i.e.:

public void run(){} -> @Override public void run(){}

could someone tell me more about this change in coding in 1.5? (or is this intellij specific?)

thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is one example of something called "annotations", new in Java 1.5. The @Overrides tells the compiler that you intended to override something; if the signatures don't match, you get a compiler error. This bullet-proofs your subclass against changes to the superclass -- at the expense of making your code 1.5-dependent, of course.

To be honest, I'm not aware of any especially good documentation on these; you can try your luck with any of the latest crop of books about "Tiger", the Java 1.5 codename.
 
Tian Zhang
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
though i read through the "what's new" in the api, but obivously left a vital section out

thanks.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!