Annotations In Java Tutorial - How To Create And Use Your Own Custom Annotations

preview_player
Показать описание
Create your own custom annotations in Java!

Annotations are a really cool part of the Java language. Many developers know how to use annotations, but not so many know how simple it is to create their own custom annotations.

In this video, we'll go over how to create 3 different types of custom annotations in Java, and how you can use those annotations to do cool things in your programs.

If you're confused by creating annotations in Java, you're in the right place!

Learn or improve your Java by watching it being coded live!

Hi, I'm John! I'm a Lead Java Software Engineer and I've been in the programming industry for more than a decade. I love sharing what I've learned over the years in a way that's understandable for all levels of Java learners.

Let me know what else you'd like to see!

Links to any stuff in this description are affiliate links, so if you buy a product through those links I may earn a small commission.

📕 THE best book to learn Java, Effective Java by Joshua Bloch

📕 One of my favorite programming books, Clean Code by Robert Martin

🎧 Or get the audio version of Clean Code for FREE here with an Audible free trial

🖥️Standing desk brand I use for recording (get a code for $30 off through this link!)

📹Phone I use for recording:

🎙️Microphone I use (classy, I know):

Donate with PayPal (Thank you so much!)

☕Complete Java course:

Рекомендации по теме
Комментарии
Автор

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!

CodingWithJohn
Автор

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.

xslicer
Автор

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 YouTube 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.

codewithenthronekingsley
Автор

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.

Pierre-wlgf
Автор

i always struggled with annotation when creating my custom ones without understanding it completely thank you very much john for this awesome explanation.

sadeepaalwis
Автор

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.

atomiccoding
Автор

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.
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.

Speiger
Автор

Hey John, thanks for all [public static final] videos. Please continue doing the good work.

ragore
Автор

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!🙏

GhostlyDream
Автор

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.

simonrozendal
Автор

Thank you so much for this. I was especially surprised at how much reflection was required for processing!

fc
Автор

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!

flexerfadrigalan
Автор

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?

maheshrphulse
Автор

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?

Felipe-yrgm
Автор

Even when I watch a video that I already know about, I can learn something new.
Thank you John!

barbosabass
Автор

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?

andtif
Автор

Awesome! I didn't even know that you can handle object methods and object variables this way! Thank you so much!

qgqgvic
Автор

Finally someone who explains this in a clear way. Thank you John

elcaballopapi
Автор

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.

chtulurr
Автор

Thank you for explaining custom annotations in such a straightforward way.

CodecrafterArtemis