String className = n.getClass().getName(); String name = className.substring(className.lastIndexOf('$')+1,className.length()-4); System.out.println(name);