#71 What is Annotation in Java

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

For More Queries WhatsApp or Call on : +919008963671

In this lecture we are discussing:
#1 What is Annotations?
#2 What does annotations provide to program?
#3 How annotation prevent us from logical error?


1)
What is Annotations?
-- annotation is type of comment which is used to provide meta data to the compiler and JVM about the program.

Basic difference between comment and annotations
-- annotation is used to provide meta data to the compiler and JVM about the program but comment is used to provide information to the programmer.

2)
What does annotations provide to program and what does for program?
-- Annotations are used to provide supplemental information about a program.
-- Annotations start with ‘@’.
-- Annotations do not change the action of a compiled program.
-- Annotations help to associate metadata (information) to the program elements i.e. instance variables, constructors, methods, classes, etc.
-- Annotations are not pure comments as they can change the way a program is treated by the compiler. See below code for example.

3)
How annotation prevent us from logical error?
class A{
public void show(){
}

public void display(){
}
}

class B extends A{
@Override
public void show(){
}
/* @Override
public void displayData(){
}
*/

//here you get error because you are not overriding the method of parent class but you are using @Override annotation
// if you are thinking I can override display() method but you should defined new method but whenever you mention @override compiler throw error that you are not override the parent class method
//it helps to avoid the logical error in the program because logical error is more difficult to find when you use annotation it helps to find the logical error
//because solving problem at compile time error is easy than solving problem at runtime


}

More Learning :

Donation:
PayPal Id : navinreddy20
Рекомендации по теме
Комментарии
Автор

Thank you so much @Telusko, I mean it's so small topic but no body has touched it. All the people are only explaining how different annotation works, but no one is explaining what they really are, GLAD YOU DID!!

ayushwho_
Автор

Best of all! I appreciate your great help to thousands of learners out there with such effective content... A Big Thanks Sir

omdobariya
Автор

One of the best teacher and good human out there!

KarthikBhatl
Автор

Good information. It's going to take me a while to watch all your new lessons. Thanks for sharing.

guitarDad
Автор

informative and to the point video on annotations

deone
Автор

thank you, it is through your videos only that i have understood this, but i wanted to say that maybe you could have explained lambdas in a more beginner friendly way, rather than talking about anonymous classes and all. for beginner i think it is easy to think of lambdas as functions declared like variables

zombiegamer
Автор

thankss sir now i understoood agter searching 10 times on web loll

dhruvyadav
Автор

Thanks for sharing. But this does not explain what annotations are in themselves. What are they? How do they behave behind the scene? Are they classes? Are they interfaces?

adilwise
Автор

My brain almost fix when we type long methods they gets into a bug 😂😂even they are right. Loll..

uday
Автор

working in programming from almost 8 years writting code, had no idea this thing exists

pakistaninsaudi
Автор

this is not a bug the two method names are different. u missed "s" in Belongs in class B

svasanth
Автор

Haha..I almost write the comment that there is no method calling the method of class A will call the method A same goes for class B.
These mistake is common specially when you working with many classes were annotation helps a lot!!

YashRajput-gjzf