Reflection in Java: 1. Get Class Name of An Object
Reflection in Java: 1. Get Class Name of An Object
Let's say You are working on automation and your client or team lead want you to write the name of the test cases which is getting executed .
Now tell me how will you do that ???
Basically, Java Reflection is a process of examining or modifying the run time behavior of a class at run time.
The java.lang.Class class provides many methods that can be used to get metadata, examine and change the run time behavior of a class.
The java.lang and java.lang.reflect packages provide classes for java reflection.
Java reflection can be used to get many information at runtime, but we will be looking at getting/fetching below info at runtime:
public ReflectionTest()
{
}
private ReflectionTest(int i)
{
}
public void m1()
{
}
private void m2()
{
}
}
public class Demo {
}
}