Thanks to Mailgun for sponsoring this video! Head to mailgun.com/john to try Mailgun today. As a few commenters have mentioned, I forgot to note that you can also use enums as an annotation parameter. Let me know if you guys have other questions about annotations!
I was wondering, can we actually make annotations like in python where you would annotate a method so that something runs before and/or after the method has ran ?
Hi John, thank you for your videos, I'm not a programmer, I'm just an enthusiast and I want you to know what your videos are really helpful and worth watching.
Would be nice to see a part 2 where you have a preprocessor for the annotation so you won't have to write logic for a specific objcet to process the annotation, but instead to be processed where you apply it.
I was just gonna come here to suggest that. It would be cool to see something like an annotation for a field that generates getters/setters (I know this isn’t something you’d actually build, but just an example) or maybe a method timer that logs how long a decorated method takes to execute. Basically, it’d be nice to see an example that shows an executable use, in addition to the flagging and data storing usage.
@@szalaytamas3184 now, let’s not go that far. There is definitely a use to these style of annotations. An actor model driven architecture can use these sorts of annotations to find and track which sorts of things to observe, for example. And a testing framework can use these sorts of annotations to mark which methods to test.
i always struggled with annotation when creating my custom ones without understanding it completely thank you very much john for this awesome explanation.
Dear John, you are something else. All your tutorials are just great. Very well simplified, straight to the point, very educative and really impactful. I have learnt a lot from you. Infact, I always read a minimum of 10 articles on the internet about a particular topic am learning at any time, watch 10 RUclips tutorials on that topic from different tutors. I always use your tutorial to drive that concept deep in my spirit. Each time I watch your tutorial, I get a signal from my spirit saying "Enthrone" you have successfully sink this in. Keep it up man. A big fan from Nigeria West Africa.
Although I have been working as a Java Software developer for more than a year, I learn something new from your videos all the time. Thanks for the tutorials. I wish I had such a Team Lead as you or worked in your team.
I love the way you explain in your videos. It is always clear and understandable. Most of all I always learn something. Thank you man. Greetings from France.
I actually have a interesting case for Annotation. I am writing a pretty big mod that is synchronizing fields automatically through networking. So you just have to request the field name to be synchronized. What you have to do is add the "@NetworkField" Annotation to the Field and it will be automatically mapped to the networking manager. Which allows me to compress information down to 1 byte instead of having to write down the fields name, since they are automatically mapped I just write down the Index it was mapped to and send the data over with the index to then use that info to gather the index automatically. Another usecase is for plugins where a Annotation is the Indicator where a class might be a plugin. Which allows you to make modding support super easy for you or other people.
I have been reading books and some articles on internet all day, and just watched this video... In 20 minutes I've understood much more then in the whole day Thank you very much!🙏
The moment I made the code work, you also showed Stella on the screen and it was the best payoff I have ever had aaw. Thanks for the videos, they have been great help for me for an interview preparation. Very clear explanations and examples.
We have found them useful particularly for annotating controller methods, to make it easy to accomplish things like validations that can be common to many, but not all of our endpoints. For example authorization, validation for particular header values, etc.
Please john make a spring boot series. I really like the way you tech. I will love to learn spring boot from you. Specifically if you make a monolithic application from the scratch then move to microservices part. We the followers of yours looking forward to it. So much love and respect for you.
I was literally in the shower thinking about what you could do as the next topic, and then an older video of yours about arrays popped up in my recommendations, and I wanted to check if you posted a video which I might've missed, and bam.
here again thanks alot for clarifying thing in the simplest term with an example. when using annotation alot in work. It really fascinating how the background thinggy work. Best Basic Java instructor in YT.
Hi! John, I love the way you teach difficult topics with a hint of fun and humour, and that makes your videos effortless to understand. Could you please make your next video on regular expressions?
Because if you were able to use your own type, you would have no way to specify a value for that element in an annotation, since you can't run methods or instantiate objects in an annotation. So for example, if you could have an annotation called Anno that takes in a value of type Cat, annotating something with it would require you to write @Anno(value = new Cat()), which is impossible, since element values aren't supposed to run logic, but can only use constant values.
Thank you very much John! I like to develop in Java very much. But today i learned something new. I like learning on a practical way very much, keep on the good work. Because there are not enough people where we can learn good things like this. I'm now a fan of your work.
John, I need to say... Your videos are freaking awesome! Excellent explanation. Could you bring more content about collections and how they work in deep, please?
John you're an absolute LEGEND for the way you explain complex things in a simple way. Please continue being you and do what you're doing. Would love to see some more advanced Java topics as others has mentioned with annotations and reflection! What you've described in this video is also, what I assume, closely related to Aspect Oriented Programming or IS in all practical sense, AOT?
John! You have amazing presentations and I am all for it. I went to subscribe right away, only to figure out I already am! Thank you for pumping out these videos. They are so helpful!
It would be awesome if you did a video about annotation processors! There are not much tutorial online, and the one there are mostly use external libraries
Hey, thank you for this video. I was always interested in annotations but never had the motivation to look at them. I also would like to have a video about the Factory Design Pattern.
Hi John ! Thanks for all your videos. Your explanations are very precise, crystal clear and whenever I have a question, you answer it a few seconds later. Thanks a lot ! I was looking for a video on java Streams which is a totally new subject for me. Your explanations on this would be really helpful. Thanks again for your work !
Heyo, you forgot to say, for parameters, you can use also Enums (without that Retention and Target Annotations would not work). Btw i love your videos, you have nice way to explain complicated things in few minutes understandable and then it seems pretty easy. Please dont stop with vids
John, you are showing how to use custom annotation at runtime: there are methods that can determine if annotation present and/or obtain its value to be used in the code. What about compile time? What can be done with it? E.g. how to make compiler to skip portion of code depending on compile time annotation?
I am learning about a couple of things, Annotations and Reflection and Aspect. However, I have a basic question, and focused on perhaps the CONTENT and CONTEXT of this video. The way John presents the topic and to use a Main method to check for Class/Method/Field annotation and if found (after looping), he does something. In this way, what real world application would we ever use a main method to loop to find annotation, then do something? (I get it that this is a tutorial of a subject not a specific application of the subject, but still am curious as to my question)
I'm mostly curious about how you'd implement custom annotations into your projects. Such as, why would you use them specifically, or how would you use them? Would you only use them on a specific class object? Because you'd have to loop through it using reflection? Or what if you have a class annotation, how would you check if a specific class is annotated without already knowing which class you add the annotation to? And if you already know that class is going to be annotated, why annotate it?
Very well explained. I was wondering if you can reject the execution of a method using annotations? For example, if the method caller does not have certain requirement.
Main content: ## What is annotations? The extra info that is used by compiler or yourself. - you put it right before the things your wanna annotate. ## how to create one? 1. a special [[class]] 1. use @Target(ElementType.?) to specify the types the annotations are for. 2. use @Retention(RetentionPolicy.RUNTIME) to specify the timing. 3. use @intervface before the class name(same as Annotation) 2. It will be attached to the class(or methods or anything specified by @Target) annotated. 1. some methods. 3. Conclusion: 1. the idea is to look at the class's annotation to act differently on it. 4. how to use it on methods. 5. how to do annotations with params ``` java //in the special [[class]] int times(); //annotaion @runImmedieately(time = 3) //main methods annotation = get...(); int _times = annotaion.times(); ``` 1. types to use for these params: no special ones. 2. it can has a default value. 6. how to do it for a field. 1. pretty much the same.
I really enjoy your videos!!! I learn something new everyday with your videos all the time :) Also can I request on how to do method referencing? I really confuses and there's not good tutorials on youtube. Thanks!!!
Hey John! As always, very nice video. I always enjoy to watch your videos. Thanks for each and every one of them. In general, even if only briefly, could you talk about what books you would recommend, especially for beginners, on one subject or another. I know it is very individual. I would still be happy about your recommendation. I’m a beguines to programming and totally a fan of your way of explaining things. Thanks again for all your work.
Thanks to Mailgun for sponsoring this video! Head to mailgun.com/john to try Mailgun today.
As a few commenters have mentioned, I forgot to note that you can also use enums as an annotation parameter.
Let me know if you guys have other questions about annotations!
Streams and Optional :) And thank you :)
I was wondering, can we actually make annotations like in python where you would annotate a method so that something runs before and/or after the method has ran ?
@@shlack Did you ask for junit ? If not just read about listeners in java, it could help you
@Henryk Zschuppan config reader, good point for tutorial.
Hi John, thank you for your videos, I'm not a programmer, I'm just an enthusiast and I want you to know what your videos are really helpful and worth watching.
Would be nice to see a part 2 where you have a preprocessor for the annotation so you won't have to write logic for a specific objcet to process the annotation, but instead to be processed where you apply it.
I was just gonna come here to suggest that. It would be cool to see something like an annotation for a field that generates getters/setters (I know this isn’t something you’d actually build, but just an example) or maybe a method timer that logs how long a decorated method takes to execute. Basically, it’d be nice to see an example that shows an executable use, in addition to the flagging and data storing usage.
Man I second that! That would be great to learn!
I think a good idea, is to implement a anotaciones to prevent null on getter or setter
Yeah. This way it's just pointless.
@@szalaytamas3184 now, let’s not go that far. There is definitely a use to these style of annotations. An actor model driven architecture can use these sorts of annotations to find and track which sorts of things to observe, for example. And a testing framework can use these sorts of annotations to mark which methods to test.
i always struggled with annotation when creating my custom ones without understanding it completely thank you very much john for this awesome explanation.
Dear John, you are something else. All your tutorials are just great. Very well simplified, straight to the point, very educative and really impactful. I have learnt a lot from you. Infact, I always read a minimum of 10 articles on the internet about a particular topic am learning at any time, watch 10 RUclips tutorials on that topic from different tutors. I always use your tutorial to drive that concept deep in my spirit. Each time I watch your tutorial, I get a signal from my spirit saying "Enthrone" you have successfully sink this in. Keep it up man. A big fan from Nigeria West Africa.
Although I have been working as a Java Software developer for more than a year, I learn something new from your videos all the time. Thanks for the tutorials. I wish I had such a Team Lead as you or worked in your team.
I love the way you explain in your videos. It is always clear and understandable. Most of all I always learn something. Thank you man. Greetings from France.
Ouais on a pas des tutos comme ça nous...
Can you please make a course on Spring boot, possiblty also incorporate databases with it and such. Your way of teaching is just unbeatable tbh...
I actually have a interesting case for Annotation.
I am writing a pretty big mod that is synchronizing fields automatically through networking.
So you just have to request the field name to be synchronized.
What you have to do is add the "@NetworkField" Annotation to the Field and it will be automatically mapped to the networking manager.
Which allows me to compress information down to 1 byte instead of having to write down the fields name, since they are automatically mapped I just write down the Index it was mapped to and send the data over with the index to then use that info to gather the index automatically.
Another usecase is for plugins where a Annotation is the Indicator where a class might be a plugin. Which allows you to make modding support super easy for you or other people.
I have been reading books and some articles on internet all day, and just watched this video... In 20 minutes I've understood much more then in the whole day
Thank you very much!🙏
Java is a beatifull language❤️
lmfao
So beautiful it will confuse you with all these annotation bs 😂
its fucking awesome. people meme on it too much.
It's certainly my cup of java, lol
❤ Java
I read the title of the video: Start watching
after completing 30% of the video: Liked
reached the 70% mark: Subscribed.
Thanks a ton.
Hey John, thanks for all [public static final] videos. Please continue doing the good work.
The moment I made the code work, you also showed Stella on the screen and it was the best payoff I have ever had aaw. Thanks for the videos, they have been great help for me for an interview preparation. Very clear explanations and examples.
The way you teach any concept is just amazing.
Thank you so much for this. I was especially surprised at how much reflection was required for processing!
Finally someone who explains this in a clear way. Thank you John
Awesome! I didn't even know that you can handle object methods and object variables this way! Thank you so much!
Yeah reflection is something. Like magic methods etc. In python.
The best explanation I have seen covering Java annotations thank you
Wow.! its crystal clear explanation..!
What probably be production Use case for Custom Annotations.
I can think of
Initialisation and closing of connection
We have found them useful particularly for annotating controller methods, to make it easy to accomplish things like validations that can be common to many, but not all of our endpoints. For example authorization, validation for particular header values, etc.
So Simple , Crisp and Clear Explanation - with extra flavour of where to use it and where not to use. thank you very much
I'm just amazed about how much more there is to learn and then apply it.
I need a complete regular expressions tutorial to create "IP filters". The way you teach us is amazing
Not sure when exactly I'll be able to get to it, but it's on the list!
Please john make a spring boot series. I really like the way you tech. I will love to learn spring boot from you. Specifically if you make a monolithic application from the scratch then move to microservices part. We the followers of yours looking forward to it. So much love and respect for you.
best teacher for beginners and advanced.......even better than mosh
Never leave me john.
I love the trick of "instance of"
Even when I watch a video that I already know about, I can learn something new.
Thank you John!
This video is about a not-so-trivial subject and still is so clear that it seems easy ✌ so great
Thank you for explaining custom annotations in such a straightforward way.
Man am I glad I found your channel, I was going crazy tying to learn Java from other videos. (I was actually about to give up and switch to Js lol)
I'm not a java developer but I enjoyed your content.
I was literally in the shower thinking about what you could do as the next topic, and then an older video of yours about arrays popped up in my recommendations, and I wanted to check if you posted a video which I might've missed, and bam.
here again thanks alot for clarifying thing in the simplest term with an example. when using annotation alot in work. It really fascinating how the background thinggy work. Best Basic Java instructor in YT.
Hi! John, I love the way you teach difficult topics with a hint of fun and humour, and that makes your videos effortless to understand. Could you please make your next video on regular expressions?
How can we specify behavior in annotations? I have seen this before but I have no idea how to apply it!
Thank you John for your videos!
Good stuff. Congratulations on the sponsorship
Thanks, John! Would love to see a lesson on Stream API for processing collections of objects.
You're legend in explaining things, many thanks man.
Hands down the best Java guru here on RUclips!! 👌
Thanks John. It was short yet comprehensive.
Thank you for the clear explanation. Can you explain why we can't use our own Type in the Annotation, but instead we can define them as enum or Class?
Because if you were able to use your own type, you would have no way to specify a value for that element in an annotation, since you can't run methods or instantiate objects in an annotation.
So for example, if you could have an annotation called Anno that takes in a value of type Cat, annotating something with it would require you to write @Anno(value = new Cat()), which is impossible, since element values aren't supposed to run logic, but can only use constant values.
Nice.. very clear explanation. Thanks !
Excepting part 2 with real time example scenarios. 😊
I don't knew this syntatic sugar after instanceof, thanks!
Been really enjoying the videos! Could you please do a video on the “static” keyword? :)
Thank you very much John! I like to develop in Java very much. But today i learned something new. I like learning on a practical way very much, keep on the good work. Because there are not enough people where we can learn good things like this. I'm now a fan of your work.
Great video man! I would love to see a tutorial on reflection one day!! It seems very interesting
Thanks for such a quality explanation of Annotations.
John, I need to say... Your videos are freaking awesome! Excellent explanation.
Could you bring more content about collections and how they work in deep, please?
Thanks John! Would love to see a lesson on regular expressions (patterns)
Great video!
Can you do separate video on getClass and Reflection?
Also, can you do series on dependency injection.
John you're an absolute LEGEND for the way you explain complex things in a simple way. Please continue being you and do what you're doing. Would love to see some more advanced Java topics as others has mentioned with annotations and reflection! What you've described in this video is also, what I assume, closely related to Aspect Oriented Programming or IS in all practical sense, AOT?
John! You have amazing presentations and I am all for it. I went to subscribe right away, only to figure out I already am! Thank you for pumping out these videos. They are so helpful!
It would be awesome if you did a video about annotation processors! There are not much tutorial online, and the one there are mostly use external libraries
The best explanation ever. Thanks
Stella is such a beautiful cat
Best video about this topic I've ever seen!
Hi John, your video are very helpful.
Can you please make a video about JRE, JDK and JVM
Hi John, Loved the way you teach. Please add a Java full stack or Spring boot series as well
Hey,
thank you for this video. I was always interested in annotations but never had the motivation to look at them.
I also would like to have a video about the Factory Design Pattern.
John - I know it is said a lot in here but I love your explanations. Even if I know the topic it is still great to watch
Awesome video. Can you make one for Futures and completables? That would be great 😀
Nice and simple explanation. Thanks!
Could you make a Spring AOP kind of video with custom annotations and using the Pointcut expressions.
13:28 This is what's done in recursion, declaration of a method without code block
Hi John ! Thanks for all your videos. Your explanations are very precise, crystal clear and whenever I have a question, you answer it a few seconds later. Thanks a lot !
I was looking for a video on java Streams which is a totally new subject for me. Your explanations on this would be really helpful. Thanks again for your work !
This will be handy when I write my own ORM.
Thank you, John! Your videos are very helpful.
Thank you, John!
Heyo, you forgot to say, for parameters, you can use also Enums (without that Retention and Target Annotations would not work). Btw i love your videos, you have nice way to explain complicated things in few minutes understandable and then it seems pretty easy. Please dont stop with vids
John, you are showing how to use custom annotation at runtime: there are methods that can determine if annotation present and/or obtain its value to be used in the code. What about compile time? What can be done with it? E.g. how to make compiler to skip portion of code depending on compile time annotation?
I am learning about a couple of things, Annotations and Reflection and Aspect. However, I have a basic question, and focused on perhaps the CONTENT and CONTEXT of this video. The way John presents the topic and to use a Main method to check for Class/Method/Field annotation and if found (after looping), he does something. In this way, what real world application would we ever use a main method to loop to find annotation, then do something? (I get it that this is a tutorial of a subject not a specific application of the subject, but still am curious as to my question)
You should do a jpa tutorial- that’s where the fun begins..,
I'm mostly curious about how you'd implement custom annotations into your projects. Such as, why would you use them specifically, or how would you use them? Would you only use them on a specific class object? Because you'd have to loop through it using reflection? Or what if you have a class annotation, how would you check if a specific class is annotated without already knowing which class you add the annotation to? And if you already know that class is going to be annotated, why annotate it?
you are awesome ❤️
Best teacher 😘
I like your teaching very much ❤️❤️❤️❤️❤️❤️❤️❤️
Excellent video John!
Awesome as always! Thanks for sharing!
Nice explanation John.
mast explain kiya John bhai
Thank you very much for this explanation!
Very well explained. I was wondering if you can reject the execution of a method using annotations? For example, if the method caller does not have certain requirement.
Excellent video about implementing a custom annotation, great content, keep going!
Thanx! Great and simple tutorial
Thank you so much! Finally i figured it out...
awesome as always, your presention is so nice, thanks for sharing!
Main content:
## What is annotations?
The extra info that is used by compiler or yourself.
- you put it right before the things your wanna annotate.
## how to create one?
1. a special [[class]]
1. use @Target(ElementType.?) to specify the types the annotations are for.
2. use @Retention(RetentionPolicy.RUNTIME) to specify the timing.
3. use @intervface before the class name(same as Annotation)
2. It will be attached to the class(or methods or anything specified by @Target) annotated.
1. some methods.
3. Conclusion:
1. the idea is to look at the class's annotation to act differently on it.
4. how to use it on methods.
5. how to do annotations with params
``` java
//in the special [[class]]
int times();
//annotaion
@runImmedieately(time = 3)
//main methods
annotation = get...();
int _times = annotaion.times();
```
1. types to use for these params: no special ones.
2. it can has a default value.
6. how to do it for a field.
1. pretty much the same.
I really enjoy your videos!!! I learn something new everyday with your videos all the time :) Also can I request on how to do method referencing? I really confuses and there's not good tutorials on youtube. Thanks!!!
Great video and you explain the consepts very well! Now, you have one more subscriber. Greetings from Turkey!
I am from india, really love your java videos, keep it up bro 🙏. Please make one video on Virtual Threads usage.
I have been working with java developing web applications for the past 3 years, i didn't know we can make our own custom annotations.
Hi John, Can you give a tutorial on getting json data from a public url using java.
thank you alot dear John
John is the flipping MVP
1:37 beginning
It is a pleasure to watch your videos
Amazing, Nice and easy explanation!
Hey John! As always, very nice video. I always enjoy to watch your videos. Thanks for each and every one of them.
In general, even if only briefly, could you talk about what books you would recommend, especially for beginners, on one subject or another. I know it is very individual. I would still be happy about your recommendation. I’m a beguines to programming and totally a fan of your way of explaining things. Thanks again for all your work.
Thanks a lot, John! Very useful tutorial.
Thanks John, it's helpful
Hi John, this is a great tutorial, thank you for that!