Try,
String className = this.getClass().getSimpleName();
This will work as long as you don’t use it in a static method.
More Related Contents:
- What is the point of abstract classes, when you could just do an interface [duplicate]
- Convert structs in C++ to class in Java [closed]
- ArrayOutOfBoundsException Error?
- Java – class, get new array of objects
- How do I correctly implement this code segment without getting a logic error? [closed]
- How do I resolve ClassNotFoundException?
- What are classes, references, and objects?
- Static nested class in Java, why?
- Determine which JAR file a class is from
- How can a class have a member of its own type, isn’t this infinite recursion?
- The connection between ‘System.out.println()’ and ‘toString()’ in Java
- Get all of the Classes in the Classpath
- Java – how to load different versions of the same class?
- Getting Class type from String
- Can I get all methods of a class?
- How to get the parent base class object super.getClass()
- Java: Class.this
- Curly braces in “new” expression? (e.g. “new MyClass() { … }”)
- Advantage of Local Classes Java
- Import a custom class in Java
- Get variable in other classes
- Cannot instantiate the type for class object (Java)
- Is the class loaded when its reference is declared?
- instanceof Vs getClass( )
- Why can’t a “Class” variable be passed to instanceof?
- Why can’t a top level class be static in Java?
- Determine whether .class file was compiled with debug info?
- Eclipse – Show generated class files
- Class must either be declared abstract or implement abstract method error
- Java: How to limit access of a method to a specific class?