Yes there is a way to print the classname in java console.
For that you need to override the toString() method in the class created by you. From the toString() method return the name of the class and use “this” keyword in println() method .
Following is the codesnnipet:
package Misc;
public class B {
public String toString(){
return "B";
}
public void testPrintln(){
String str = "test string";
System.out.println(this+str);
}
public static void main(String[] arg){
new B().testPrintln();
}
}
Hope this is your solution..