I have a classA which contains following code snippet:
public classA {
public static Integer getValue(int x) {
system.out.println(x);
System.out.println(Qualifiedclassname that where you got the xvalue);
return x;
}
}
The above class contains a method called getValue() which returns int as its declared as argument. This method would be called in another class files like below:
public class B {
@Parameters{value}
public static void setValue(int value) {
ClassA.getValue(value);
}
}
I just want to get a "class name" of the value where I'm getting it. As per above code Class B is giving a value for the getValue() method. I would like to print a class name of b in output console as "com.online.getvaluecode.ClassB".
As per my requirement, I can't use any of the below code in ClassB(client level code, but it can be used in Class A inside getValues()method):
this.getClass().getName(); or
Class<?> enclosingClass = getClass().getEnclosingClass();
enclosingClass.getName();
Class B always used to call ClassA.getValue(x) method, and It has to print the value as well "class name" where I'm getting int value for that method. I don't have permission to use any object creation in ClassB. All I have to do, call the ClassA.getValue(x);