Sunday, November 6, 2011

Re: [android-developers] First Question ... be gentle

Just to make it clear, that's an "Annotation" not a comment.
Comments are ignored by the compiler, annotations are actually evaluated by the compiler in compile time and sometimes during runtime too.


from the documentation:

Annotations have a number of uses, among them:
Information for the compiler — Annotations can be used by the compiler to detect errors or suppress warnings.
Compiler-time and deployment-time processing — Software tools can process annotation information to generate code, XML files, and so forth.
Runtime processing — Some annotations are available to be examined at runtime.

2011/10/28 John Davis <davisjf@gmail.com>
2011/10/28 Francisco Dalla Rosa soares <soares@argo.bz>:
> http://lmgtfy.com/?q=java+override
> I can't of nicer way to do this :)
>
>
> 2011/10/28 JBlaza <jblaza@gmail.com>
>>
>> I have looked on several other forums. i am new to the java programming
>> community, and i am looking for a clear understanding of the @overide
>> annotation, and what it does, or signifies.
>>

The override part is a comment.  It means that the routine exists
already in your class or parent(s) class and that you have decided to
do it differently from the already implemented code.
In other words, you have created a new class derived from an existing
class.  The existing class or one of its parent classes has
implemented a function.  You want to change the  behaviour of
that funciton so you override it by creating the same function in your class.

Possibly I am not sure, but the keyword might also check your function
parameters and return class to ensure that
you are correctly matching the existing function as a check. Said
another way, there exists a class called Foo and you derive from it
with a class called MyFoo.  Foo implements
a routine called void doIt(int a);  You want to override it.  In
eclipse, you type doI - and then ctrl-space and it auto-completes to
the function signature with empty brackets and the @override keyword.
Somewhere along the way, you change the funciton parameter to a float,
but you leave the @override keyword there.  As far as the compiler
goes, this is legal, but with the override syntax there
the compiler will flag that the routine is not really overriden since
doIt() requires a int parameter and not a float.

--
John F. Davis

独树一帜

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en



--
株式会社アルゴ ARGO Inc.
〒130-0012
東京都墨田区太平3-11-10
NTKオオノビル8階

ソアレス フランシスコ ( Soares Francisco )
Mail : soares@argo.bz HP : http://www.argo.bz/
TEL:03-5619-4511 FAX:03-5619-4512

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

No comments:

Post a Comment