Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- final static Logger logger = LoggerFactory.getLogger(getClass());
- final static Logger logger = LoggerFactory.getLogger(my.package.name.MyClass.class);
- String.getClass()
- Object o = new String();
- o.getClass() // returns Class<String>
- Object.class // returns Class<Object>
- public class Object {
- public static Class<?> getClass2() {
- return ...?
- }
- }
- Class<?> cl=new Object(){}.getClass().getEnclosingClass();
- static class Bar {
- public static void main(String[] args) {
- Class<?> cl=new Object(){}.getClass().getEnclosingClass();
- System.out.println(cl==Bar.class); //will print true
- }
- }
- Interface foo = new FooImpl();
- foo.getClass(); // returns Class<FooImpl> because the runtime type is FooImpl.
- // If getClass() was static, it would return Class<Foo>.
- static Logger logger = LoggerFactory.getLogger(); // auto detect caller class
Add Comment
Please, Sign In to add comment