Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Weather App (2015) Concurrency and Error Handling Making Our Code Asynchronous

Jian Chen
Jian Chen
4,938 Points

Whats does @Override mean?

Does @Override affect the how the code runs? what does it mean?

Iman Mk
Iman Mk
6,223 Points

With @Override you are letting the compiler know that the method is overriding the parent class or the interface.

More info: http://stackoverflow.com/questions/94361/when-do-you-use-javas-override-annotation-and-why

Let me know if you have any questions!

1 Answer

The override annotation is mostly for us. It's marking a method that we're overriding from a higher class our class is inheriting. The reason we would do this is to define the exact perimeters that our class needs from this already written method. Take for instance the onCreate() method we use from the android sdk: in it's simplest form, onCreate() is only telling our app the least information to create a start layout for the app. We override it, or redefine it, to let the app know exactly what we need laid out at the start of the app. Since the onCreate() method is already written in it's most basic form, we override it with the exact perimeters that our app uses, and mark it with @Override, so that anyone reading our code knows to refer to the parent class for the most vague definition of what we've redefined to be more specific for our use. Does that clear things up?

Nicolas

Jian Chen
Jian Chen
4,938 Points

Thank you Nicolas, that does clear things up.