Do you really mean "variables"? Or do you mean "fields"?
In
Java, "variable" generally means the local variables used in methods. There is no way in normal Java to find out these names. Depending on how you compiled your class (with or without debug information), there may be no way at all. But
very few applications need to know the local variable names. If you think you need to know them, and you are indeed a beginner, it's almost certain that you don't need them, and just need a better design.
In contrast, "field" means the values that are part of an object instance, or a class (static fields). These can be obtained by Java Reflection, using methods of java.lang.Class.
getFields() will get all public fields, inherited or not.
getDeclaredFields() gets all fields, directly declared in the class, whatever their access level.
If you need all fields, in the class and its superclasses, you'll need to code a loop, and use getSuperclass() in the loop.