How to get all variable name in Java

Get all variable name in Java

In this example, I am sharing simple program about, How to get all variable name in Java. The program were tested and output shared in the post.

1) Simple POJO(plain old java object) class

2) Getting all name from particular class using java reflection

Output

—-

custId
custName
custAddress
custAge

Refrences

1. Java Reflection API
2. Java Field API