Hi Derek, thank you so much for making these tutorials. I am 14 years old and I started watching these tutorials about a year ago, and they've really helped me. You take things that normally sound super complex and hard to comprehend, and make it extremely easy to learn. Keep it up!
Thousands of clicks of the suggestion videos finally led me to your channel. Your channel, sir, deserve a 500px*500px banner on the youtube front page, because it is a hidden gem! Your explanation of concepts is so clear and the way you deliver it is so special. Thank you for the amazing tutorials.
Thank you :) Reflection is taught in weird ways and I think that is what is confusing. When you approach it as just any other API it becomes easy to understand
Well thank you :) I just really enjoy making the videos and I'm glad there are people out there that like watching them. I look back at my PHP tutorial as a lost opportunity in which could have made it really great. I wasn't getting any views though so I kind of rushed the login script stuff and I shouldn't have done that. I'll fix that in the future. Thanks for the kind words :)
You can create classes dynamically using code generation libraries that are out there. Do a google search for that phrase and you'll find them. Add java to the search phrase. I hope that helps
The Observer design pattern is also know as Model/View, Dependent, Distributor/Listener subscriber pattern. You don't need reflection to implement this pattern. Take a look at my tutorial on the Observer Design Pattern. It should clear some things up.
Thank you :) In the real world I always give everything very detailed names. My OOD tutorial and the refactoring one are probably the only ones in which I show how I really program
Started working on a 3rd year Assignment that required Reflection basics to grab infos out of various files. I was having really hard time as to where to start because the concept was pretty vague to me and you just taught me the whole idea in 30 min video . Thanks mate really helped alot 👍
Great series and tutorial style. I like the speed since if I think you are going too fast I can easily rewind. Watching someone who is too slow, especially with coding, is aggravating. One tip is to try to make sure the code statements mostly show up on the screen, and not covered by side panels. You can double click on a tab to maximize to show it in all its glory and double click again to return to normal view. Thanks again!
I'm sorry, but I don't understand the question. The prototype design pattern is actually used to change an object and its methods dynamically. I'll cover other patterns that do that as well soon
Try{ System.out.println("Hello as you asked!"); } catch(Exception e){ Log.error("Damn it", e); } finally { System.out.println("Thank you for this very useful video =]"); }
Thank you so much for this Derek! Exactly what I needed - you're round about watching it more than once, but I'd rather it all be in one video that spilt over several.
I normally only use reflection for testing and for personal projects. If I'm working in a team, or on code that has any chance of being updated by someone other then me I avoid it.
Don't worry, i won't make the same mistake I made with my PHP tutorial. I'll cover every single Java tool available this time if I have to make Java tutorials for another 6 months. I already plan to cover making Android apps for at least 6 months or more. Everything will be covered by the end :)
Hey Derek Great video covering the basics of Java Reflection. Came here after reading the Java Trail on Reflection. I found your examples much easier to understand as opposed to the ones covered in the documentation which I found a bit contrived. It was worth the head-scratching, but nothing beats a down-to-earth explanation.
I'm sorry, but I don't understand the question. Are you trying to convert an int into a String? You'd do that like this newString = Integer.toString(integerVar) If that isn't what you were looking for ask and I'll be happy to solve any questions
Well the simple way to do this would be through a collection. They allow you to define variable names and values dynamically. To do it in an uncommon way you could use an annotation processor. There are other odd ways to accomplish this, but they mostly wouldn't be good. Why not just use a collection?
Thank you very much :) It isn't to hard to find out how much I make from videos online. I definitely have a job. I run a ton of shopping cart sites and write custom programs
So you want to know how to compile java to machine code? I've never used Raspberry Pi but it seems like fun :) Have you looked at the GNU Compiler for Java?
Fricking love the videos Derek,by far some of the most complete and well done Java tutorials on UA-cam IMHO. Do you have a job? Or do you just make epic tutorials for us everyday :)
Nice. Very Informative and helpful. We have used java reflection in our project in implementing the custom field validator framework to identify and show which fields have bad input to user.
I'm calling the UFOEnemyShip constructor that has the parameters int and string with getConstructor(int.class, String.class). With the other I return an array of the constructors and pick the one that has the parameter EnemyShipFactory. Does that help?
Gui libraries will often use reflections for buttons and sliders, as it allows for easier code from the user to instance buttons and to create a link from a button constructor, to a method parameter that needs to be toggled or have its value change.
Thank you :) Feel free to send me a message in UA-cam, or on my website. I don't check facebook / Twitter very often, but I check YT numerous times a day
thanks Derek... i will look at the GNU Compiler for Java... its very interesting project... we have to track the sun and move the solar panel accordingly... thanks once again....
What's the point of getting a field's value by passing its (string) name instead of just calling the getter for it? Example on 20:30. What use case would suggest using this technique?
Hello, please mention where you create the EnemyShipFactory variable from (where is the class), because I had to go through your cheatsheet to see it was from a different lesson. Thank you!
He's actually right. I've chosen to follow your course among many others, mainly because of the way you explain things, but also because of your encouraging voice. Funny enough, now when I read a book on Java, your voice kind of sounds in my head. Thanks a lot for sharing your knowledge in a very easy and enjoyable way!
Liked the lesson a lot. Just to clarify one point which confused me at first. The two lines of code can be modified slightly for clarity: Constructor constructor = null; Object constructor2 = null; I thought that constructor2 was also an constructor but it is intended to be a Object for the new instance. Perhaps: Object newInstance = null; // Use newInstance instead of constructor2 in the code
Why does makeShip method not show in the output (pls see 10:50 sec in the video)? Btw, I added another void method called testthis and it showed up. I could not force makeShip to show in the output. Even the 'constructor' method does not show up.. not sure why. Any and all explanation is most appreciated. Thank you in advance.
I do my best. I think this is exactly what you are looking for javaranch . com/journal/200711/Journal200711 . jsp#a4 Tell me if that helps? It might make for a fun tutorial
It's an amazing video! I had no ideea what reflection meant before watching it, it was indeed a mistery to me. Now I can't wait to work with it :D. Thanks a looooot!!!
Excellent tutorial is really clear,I just would like to ask you a quick question. It is possible to reflect at runtime?Let say that I have an application in java and this was compiled in a file called Application.jar, then I open this application, I log in and I open an user interface that were populated with a class giving fields values. Then can I reflect this information using reflectio?What I would like to do is a kind of API that scrap fields values & after automate it.Thank you!!
I don't know how I got into the habit of using those catch phrases? It is weird how things happen. I dare not start a video without hello internet though. I did that once and everyone went crazy :)
I like this thank you so much!!! I know i am asking a big favor but if you get a chance can you cover spring, because make complicated topics easy to understand in less time. Thank again.
Thulasi Prasad any one know if i have input coming in through a jtextField in a private method, how I should go about accessing the string inside of the method, so i can manipulate out side of that method.
@Derek Banas this design pattern seems to be too specific to Java, isn't it? please correct, if I am wrong (since, I would try out the concept in C++)..
Sorry I phrased that poorly! I meant that in C++ they use pointers to support the delegate design pattern... Would reflection be the way that java supports delegation? Just wondering as studying design patterns in College and we code in java and this is a current question on one of my midterms...just doing a bit of research! Thanks
Reflection in Python docs.python.org/3.5/c-api/reflection.html Reflection examples in C++ stackoverflow.com/questions/41453/how-can-i-add-reflection-to-a-c-application
Hi Derek, So I was experimenting with something recently - and I am unable to solve it. From your tutorial you show how we can invoke a method of our choosing dynamically with java reflection API. This is pretty cool. I am looking to dynamically provide code or compiled objects - so I not only want to dynamically choose what to execute but dictate what that method does on the fly. I am trying to write software knows the version numbers of all of its modules and tries to listen to a socket for new messages. The messages can contain modules as java object stored in byte arrays - if the software detects that the software module version on an in coming message is greater/ newer than the one its currently using, it replaces its existing module with the one just received. In other words you are able to do a software update/ change functionality without rebuilding and re-deploying the jar. Is this doable ?
Hi Derek, thank you so much for making these tutorials. I am 14 years old and I started watching these tutorials about a year ago, and they've really helped me. You take things that normally sound super complex and hard to comprehend, and make it extremely easy to learn. Keep it up!
***** You're very welcome :) My goal with every video is to make everything easy to understand. I'm happy I was able to help.
holy u 14 and doing coding .lol Wish I could have also done the same 🥺
You're welcome :) Reflection isn't that hard. I'm glad to have been of help
Thousands of clicks of the suggestion videos finally led me to your channel. Your channel, sir, deserve a 500px*500px banner on the youtube front page, because it is a hidden gem! Your explanation of concepts is so clear and the way you deliver it is so special. Thank you for the amazing tutorials.
I love this so much this breaks everything that Java and Object Oriented Programming stands for.
You're very welcome :) I'm very happy that you enjoyed the fast pace. I don't know why nobody else makes fast videos
It is sometimes difficult to catch up though interested on topic.. Specially after mid day meal
Thank you :) Reflection is taught in weird ways and I think that is what is confusing. When you approach it as just any other API it becomes easy to understand
Well thank you :) I just really enjoy making the videos and I'm glad there are people out there that like watching them. I look back at my PHP tutorial as a lost opportunity in which could have made it really great. I wasn't getting any views though so I kind of rushed the login script stuff and I shouldn't have done that. I'll fix that in the future. Thanks for the kind words :)
You're very welcome. Spring will be covered soon. I won't stop the java tutorials until I've covered everything
Wow eight years later I'm still finding this very helpful, thanks a bunch.
I'm very happy that you enjoyed it :)
You can create classes dynamically using code generation libraries that are out there. Do a google search for that phrase and you'll find them. Add java to the search phrase. I hope that helps
The Observer design pattern is also know as Model/View, Dependent, Distributor/Listener subscriber pattern. You don't need reflection to implement this pattern. Take a look at my tutorial on the Observer Design Pattern. It should clear some things up.
I like how you talk. Makes it sound so easy to do this, and every thing is comepletely obvious.
Thank you :) In the real world I always give everything very detailed names. My OOD tutorial and the refactoring one are probably the only ones in which I show how I really program
I am watching your tutorial after 10 years of uploading of this and it is totally usful... thanks
Thank you :)
Started working on a 3rd year Assignment that required Reflection basics to grab infos out of various files. I was having really hard time as to where to start because the concept was pretty vague to me and you just taught me the whole idea in 30 min video . Thanks mate really helped alot 👍
+Moonis Ahmed I'm very happy that I could help :)
Yes sort of. You can change just about anything because reflection allows you to break all the rules. In what way do you want to change them?
Loaded with easy to understand examples. Dissects reflection and lays it bare. Excellent tut on java reflection api.
Great series and tutorial style. I like the speed since if I think you are going too fast I can easily rewind. Watching someone who is too slow, especially with coding, is aggravating.
One tip is to try to make sure the code statements mostly show up on the screen, and not covered by side panels. You can double click on a tab to maximize to show it in all its glory and double click again to return to normal view.
Thanks again!
You're very welcome :) Yes the speed of my tutorials is what makes me different. I'll do my best to improve on keeping the code on the screen.
It isn't commonly covered and it is vastly misunderstood for some reason. I like to clear up topics like this :)
I'm sorry, but I don't understand the question. The prototype design pattern is actually used to change an object and its methods dynamically. I'll cover other patterns that do that as well soon
Try{
System.out.println("Hello as you asked!");
} catch(Exception e){
Log.error("Damn it", e);
} finally {
System.out.println("Thank you for this very useful video =]");
}
You're very welcome :) I'm glad I'm able to teach about these niche subjects and clear them up a bit
Derek , all your tutorial videos are absolutely superb. Thank you for putting these and helping the developer community.
haricharan kanduri Thank you for the nice compliments :)
I was upside down in this. Was ashamed to ask for help to anyone.
But the Intellectual Generous Genius that you are ,
you Bailed me out , again :)
Thank you very much for the kind message :) I'm glad you enjoy them. Yes, I'm not that popular, but that is ok because my community is very nice!
Thank you so much for this Derek! Exactly what I needed - you're round about watching it more than once, but I'd rather it all be in one video that spilt over several.
I normally only use reflection for testing and for personal projects. If I'm working in a team, or on code that has any chance of being updated by someone other then me I avoid it.
No this isn't in reference to ReflectASM. This is about the Java Reflection library. I'll see what I can do about a tutorial on that subject
Don't worry, i won't make the same mistake I made with my PHP tutorial. I'll cover every single Java tool available this time if I have to make Java tutorials for another 6 months. I already plan to cover making Android apps for at least 6 months or more. Everything will be covered by the end :)
Absolutely beautiful tutorial! Loved that the code is easily accessible and not behind a paywall! Learned a lot, thanks!
Thank you for the nice compliment :) I'm very happy you enjoyed it
Hey Derek
Great video covering the basics of Java Reflection. Came here after reading the Java Trail on Reflection. I found your examples much easier to understand as opposed to the ones covered in the documentation which I found a bit contrived. It was worth the head-scratching, but nothing beats a down-to-earth explanation.
Thank you :) I'm very happy that I was able to clear up reflection.
I think your voice amazing. You are explaining everything so well..and that voice adds so much to your lessons.
blissB2 Thank you for the compliment :) I appreciate them greatly.
Ahhh... you voice... Not creepy
As always, this guy is a terrific explainer.
+Roy lee Thank you :) I'm glad I could help
I'm sorry, but I don't understand the question. Are you trying to convert an int into a String? You'd do that like this
newString = Integer.toString(integerVar)
If that isn't what you were looking for ask and I'll be happy to solve any questions
That is built into the class and has to do with Threads. I wouldn't worry about it. I talk about threads in other Java tutorials
You are able to normally access any classes in the same package using reflection
Thank for doing this video on java reflection api. It’s very comprehensive and well explained.
Thank you 😃 Happy to help
Well the simple way to do this would be through a collection. They allow you to define variable names and values dynamically. To do it in an uncommon way you could use an annotation processor. There are other odd ways to accomplish this, but they mostly wouldn't be good. Why not just use a collection?
Thank you very much :) It isn't to hard to find out how much I make from videos online. I definitely have a job. I run a ton of shopping cart sites and write custom programs
Thanks a lot Derek.
Had some trouble getting the concept into practice, but the video really helped crack it. You're on my awesome list.
You're welcome :) I'm glad to be able to help
21:23 "put some more try catch blocks!" haha! Awesome tutorial man. I have also learnt a lot from your other design pattern videos. Thanks!
+Nikhil Verma You're very welcome :)
Thank you :) I love to make complicated topics easy to understand
So you want to know how to compile java to machine code? I've never used Raspberry Pi but it seems like fun :) Have you looked at the GNU Compiler for Java?
You're very welcome :) I'm glad I could help
I'm glad I could help :) Thank you
Fricking love the videos Derek,by far some of the most complete and well done Java tutorials on UA-cam IMHO. Do you have a job? Or do you just make epic tutorials for us everyday :)
Thank you very much :) I'm very happy to be able to help
It sounds fascinating! I'll have to check out Raspberry Pi :)
Reflectasm generates code, while the java reflection API doesn't. That is the main difference
Thanks, man! Your explanation is very clear...
It helped me a lot!
Waiting for more!
Hi Derek,
This is one of the best tutorial i came through. Great job.
Bhupinder Singh Thank you :) I'm glad you liked it.
Thank you :) You're very welcome
Nice. Very Informative and helpful. We have used java reflection in our project in implementing the custom field validator framework to identify and show which fields have bad input to user.
I'm calling the UFOEnemyShip constructor that has the parameters int and string with getConstructor(int.class, String.class).
With the other I return an array of the constructors and pick the one that has the parameter EnemyShipFactory.
Does that help?
Thanks so much man...this REALLY helped, the entire explanation was quite clear. A bit fast at times, but that's what rewinding is for ;) Subscribed.
Thank you :) This was a long one to make
When and why we use reflection? Only for testing?
Do we use reflection with the same purpose in Spring?
Gui libraries will often use reflections for buttons and sliders, as it allows for easier code from the user to instance buttons and to create a link from a button constructor, to a method parameter that needs to be toggled or have its value change.
Spring Data JPA Repositories use Reflection API in the background to create and execute your database queries.. pretty cool if you ask me!
It started as a 52 minute video before editing :)
The way you explain it, I would not mind watching 52 min video. Thanks
Thank you :) That is coming up very soon
I'm not sure what you mean by wait methods? In this tutorial
The way You are doing is really cool man..
Thank you :) Feel free to send me a message in UA-cam, or on my website. I don't check facebook / Twitter very often, but I check YT numerous times a day
Really helpful...Thanks Derek < 3
Your welcome :) I'm glad it helped
thanks Derek... i will look at the GNU Compiler for Java... its very interesting project... we have to track the sun and move the solar panel accordingly... thanks once again....
What's the point of getting a field's value by passing its (string) name instead of just calling the getter for it? Example on 20:30.
What use case would suggest using this technique?
You're very welcome :)
Hi Derek! Thanks for your videos! They are really great!
Greetings from Brazil!
David Oliveira You're very welcome :) I'm amazed that people all over the world watch my videos.
Brasiiiiiiiiiiiiiiil! =)
You should man, a lot of people would like it!! Ps: what the difference btw this and ASM
your video really clear my understanding for reflection, thanks
Thank you :)
best reflection tutorial ever! thank you
Thank you :) I'm glad it helped
Hello, please mention where you create the EnemyShipFactory variable from (where is the class), because I had to go through your cheatsheet to see it was from a different lesson. Thank you!
Good tutorial. We can create instances in factory using reflection classForInstance instead of ifelse.
Discovered you today, good stuff!
Thank you :) I’m happy the video helped
Thanks for reflecting your knowledge to us Derek! :)
That's funny :)
He's actually right. I've chosen to follow your course among many others, mainly because of the way you explain things, but also because of your encouraging voice.
Funny enough, now when I read a book on Java, your voice kind of sounds in my head.
Thanks a lot for sharing your knowledge in a very easy and enjoyable way!
Liked the lesson a lot. Just to clarify one point which confused me at first. The two lines of code can be modified slightly for clarity:
Constructor constructor = null;
Object constructor2 = null;
I thought that constructor2 was also an constructor but it is intended to be a Object for the new instance.
Perhaps:
Object newInstance = null; // Use newInstance instead of constructor2 in the code
Corey Cotton Sorry about any confusion that caused
It is a gorgeous tutorial. Thank you so much, Derek!
Thank you very much I'm happy I could help :)
Why does makeShip method not show in the output (pls see 10:50 sec in the video)?
Btw, I added another void method called testthis and it showed up. I could not force makeShip to show in the output. Even the 'constructor' method does not show up.. not sure why. Any and all explanation is most appreciated. Thank you in advance.
Thank you :)
I do my best. I think this is exactly what you are looking for javaranch . com/journal/200711/Journal200711 . jsp#a4 Tell me if that helps? It might make for a fun tutorial
10:35 to 10:43 Right bottom of the screen
Method name: wait
return Type: void
parameters
long
Your tutorial is awesome. The extra newlines hurt.
Thank you :) Sorry about that
Amazing presentation...wonderfully designed tutorials ...
One of the best tutorial , you could have made it available in udemy , this shouldn't be free
I'm very happy you liked it :)
It's an amazing video! I had no ideea what reflection meant before watching it, it was indeed a mistery to me. Now I can't wait to work with it :D. Thanks a looooot!!!
+Roxana Pop You're very welcome :) I'm glad I could clear up reflection.
Excellent tutorial is really clear,I just would like to ask you a quick question. It is possible to reflect at runtime?Let say that I have an application in java and this was compiled in a file called Application.jar, then I open this application, I log in and I open an user interface that were populated with a class giving fields values.
Then can I reflect this information using reflectio?What I would like to do is a kind of API that scrap fields values & after automate it.Thank you!!
I don't know how I got into the habit of using those catch phrases? It is weird how things happen. I dare not start a video without hello internet though. I did that once and everyone went crazy :)
I like this thank you so much!!! I know i am asking a big favor but if you get a chance can you cover spring, because make complicated topics easy to understand in less time. Thank again.
Hi Derek, thanks for the tutorial...where can i ask question if i have related to other topics in java?
Nice video! Even understandable for german students. Thanks!
DutzelKP Thank you :) I'm glad I could help.
Hi and thank you for this video... would reflection be seen as an alternative to the delegate design pattern which is seen in C++??
Yes, absolutely right buddy!! Because c++ isn't that much dynamic in nature.
You could do that, but I couldn't explain it in a comment. I'm guessing since he didn't respond he wasn't that interested :)
Very Clear and Quick...!!
Thank you..!!
Thank you and you're very welcoeme :)
Thulasi Prasad any one know if i have input coming in through a jtextField in a private method, how I should go about accessing the string inside of the method, so i can manipulate out side of that method.
Good video! Can't find the the next tutorial video for Reflection in the real world scenario..
@Derek Banas this design pattern seems to be too specific to Java, isn't it? please correct, if I am wrong (since, I would try out the concept in C++)..
Sorry I phrased that poorly! I meant that in C++ they use pointers to support the delegate design pattern... Would reflection be the way that java supports delegation?
Just wondering as studying design patterns in College and we code in java and this is a current question on one of my midterms...just doing a bit of research! Thanks
This is so useful! I never knew this existed until now! Do we have something similar in other languages like Python or C++?
Reflection in Python docs.python.org/3.5/c-api/reflection.html
Reflection examples in C++ stackoverflow.com/questions/41453/how-can-i-add-reflection-to-a-c-application
Great video. Easy to follow
Thank you :) I'm very happy to be of help
Hi Derek, So I was experimenting with something recently - and I am unable to solve it. From your tutorial you show how we can invoke a method of our choosing dynamically with java reflection API. This is pretty cool. I am looking to dynamically provide code or compiled objects - so I not only want to dynamically choose what to execute but dictate what that method does on the fly. I am trying to write software knows the version numbers of all of its modules and tries to listen to a socket for new messages. The messages can contain modules as java object stored in byte arrays - if the software detects that the software module version on an in coming message is greater/ newer than the one its currently using, it replaces its existing module with the one just received.
In other words you are able to do a software update/ change functionality without rebuilding and re-deploying the jar. Is this doable ?