+ 4

Annotations

'@' Can please anyone tell what does this '@' this do and how do I use it in java.

22nd May 2017, 3:29 AM
Luyanda
Luyanda - avatar
4 Respostas
+ 7
The title actually answers the question. @ is an annotation. Meaning that it is added text for you or the compiler to enforce whatever you want to happen, will happen. The classic example, also given in the link provided by @KINGDX is Override. @Override is used before overriding a method. Why? It tells you this method is going to override a method in some extended class. It will also force the compiler to throw an exception (an error) if the method is NOT overriding anything. This is exactly what you want, because if there's an error you know right away it's not working properly. The programs functionality does not change by using this @Override, again it's just an annotation for you and the compiler before run time.
22nd May 2017, 4:06 AM
Rrestoring faith
Rrestoring faith - avatar
+ 11
I was just reading about this the other day! It's a system for making notes or specifying some behavior. For instance, you can mark your overrides of inherited methods, suppress warnings (caution with that one, though), or even set up certain configurations (I've seen it most related to beans, myself). With luck, we'll draw an expert to give us more info, but I hope this is of some use.
22nd May 2017, 3:44 AM
Jim
Jim - avatar
22nd May 2017, 3:41 AM
CHMD
CHMD - avatar
+ 2
Thanks guys
22nd May 2017, 3:19 PM
Luyanda
Luyanda - avatar