Is it possible for a static method in a class, get the name of the calling class. I would like to be able to use this in a static class currently used to make logs.
public class Log {
static void log(Class a, String b){
System.out.print("[" + time() + "|" + a.getName() + "]" + " " + b);
}
static void logLine(Class a, String b){
System.out.println("[" + time() + "|" + a.getName() + "]" + " " + b);
}
static void log(Class a, String[] b){
for(int c = 0; c < b.length; c++){
Log.logLine(a, b[c]);
}
}
static String time(){
return "" + java.time.LocalTime.now();
}
}
I would like to know if I can access the name of the class without needing to pass it in the method.