Reflection is a feature in the Java programming language. In Java, reflection allows us to inspect and manipulate classes, interfaces, constructors, methods, and fields at run time.
It allows an executing Java program to examine or "introspect" upon itself, and manipulate the internal properties of the program. For example, it's possible for a Java class to obtain the names of all its members and display them.
Learn what Java reflection is with examples, learn how to view methods and fields in a class.
We can inspect and modify different fields of a class using various methods provided by the Field class.
getFields() - returns all public fields from the class and its superclass
getDeclaredFields() - returns all the fields of the class
getModifier() - returns the modifier of fields in integer form
set(classObject, value) - set the value of a field with the specified value
get(classObject) - get the value of a field
setAccessible(boolean) - make the private field accessible
Like fields, we can inspect different methods of a class using various methods provided by the Method class.
getMethods() - returns all public methods of the class and its superclass
getDeclaredMethod() - returns all methods of the class
getName() - returns the name of methods
getModifiers() - returns the access modifier of methods in integer form
getReturnType() - returns the return type of methods
References for Further Reading:
https://www.oracle.com/technical-reso...
https://www.programiz.com/java-progra...
Support Lemubit Academy on Patreon and get lovely benefits as an appreciation 😃: / lemubitacademy
If you enjoyed this video, consider 🔴subscribing to be a part of the Lemubit Academy Network: https://bit.ly/2O2x0H1
Courses 📚 📚 📚 📚 📚 📚 📚 📚 📚 📚 :
📚 Java Generics, Collection Framework And Streams
https://www.udemy.com/course/java-gen...
📚 Modern Java Programming Course:
https://www.udemy.com/course/modern-j...
📚 Java Lambda Expressions And Functional Interfaces:
https://www.udemy.com/course/java-lam...
Connect With Lemubit Academy And Lemuel Ogbunude 🔍:
🌐Website: https://www.lemubitacademy.com/
🏢Linkedin: / lemuelcco
📸Instagram: / lemubitacademy
Auf dieser Seite können Sie das Online-Video #1 What is Java Reflection - Java Reflection API Tutorial mit der Dauer stunde minuten sekunde in guter Qualität ansehen, das der Benutzer Lemubit Academy 17 August 2020 hochgeladen hat, den Link mit Freunden und Bekannten teilen, dieses Video wurde auf Youtube bereits 11,861 Mal angesehen und es wurde von 83 den Zuschauern gefallen. Viel Spaß beim Betrachtenden Zuschauern gefallen!