Java Reflection Tutorial: Create Java POJO use Reflection API to get ClassName, DeclaredFields, ObjectType, SuperType and More…

Best programmatically way to get all Declared Class Fields in Java using Reflection APIs



In this tutorial I’m going to 1st write simple Java POJO and will perform all Java Reflection Examples on POJO. You must have heard of Term POJO. What is Plain Old Java Object?

Also if you have below questions then you are at right location:

  • java – How to create a POJO?
  • java – Create simple POJO classes
  • Plain old Java objects (POJOs) in Java
  • Introduction to POJO (Plain Old Java Object)
  • Designing the POJO class
  • Create 1st Java POJO class Person

POJO is just a plain, old Java Bean with the restrictions removed. Java Beans must meet the following requirements:

  1. Follow the Bean convention of getFoo (or isFoo for booleans) and setFoo methods for a mutable attribute named foo; leave off the setFoo if foo is immutable.
  2. Default no-arg constructor
  3. Must implement

POJO does not mandate any of these. It’s just what the name says: an object that compiles under JDK can be considered a Plain Old Java Object. No app server, no base classes, no interfaces required to use.


Let’s create POJO class called CrunchifyPOJO.



Now let’s have Java Reflection's Example based on this POJO.

Take a look at below Example class which covers total 9 different Java Reflection API’s examples:

Are you running a Java program? What if you want to inspect classes, interfaces, fields and methods atruntime, without knowing the names of the classes, methods etc. at compile time. Well, with the help of Reflection it’s very easily possible. Reflection is commonly used by programs which require the ability to examine or modify the runtime behavior of applications running in the Java virtual machine. Regarding Java Reflection If you have any of below questions then you are at right location:

  • Java Reflection Tutorial for Classes, Methods, Fields
  • Dynamic Class Loading using Java Reflection API
  • Take an in-depth look at the Java Reflection API
  • java api reflection – How to create an object using Constructor object
  • reflection – How do I invoke a Java method
  • How to use Reflection to call Java method at runtime
  • java reflection invoke method without arguments
  • How to get the Class’s Name, CanonicalName and SimpleName
  • Let’s find out if class object represents an Array class

Leave a Comment