Reflection in Java

Rahul
2 min readSep 14, 2019

--

https://www.udemy.com/course/introduction-to-generics-in-java/learn/lecture/3321048#overview

Hibernate, Spring, Junit use reflection and rely heavily on annotations.

We are able to get field variable for a given class, we are able to get superclass of a given class, we are able to get Information whether there are any annotations on that given class or not.

1st way to get class Name:-

2nd and more appropriate way to get class name:-

Get Package Name:-

Get Fields/ Variable Name:-

Get Field/ Variable Type:

Get Private Fields as well:-

So in short we can get ClassName, Method Name, Variable/Field Name, Private fields and methods, Superclass, Interface name and Annotations as well by reflection .

--

--

No responses yet