Guest User

Untitled

a guest
Jul 15th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. final static Logger logger = LoggerFactory.getLogger(getClass());
  2.  
  3. final static Logger logger = LoggerFactory.getLogger(my.package.name.MyClass.class);
  4.  
  5. String.getClass()
  6.  
  7. Object o = new String();
  8. o.getClass() // returns Class<String>
  9. Object.class // returns Class<Object>
  10.  
  11. public class Object {
  12.  
  13. public static Class<?> getClass2() {
  14. return ...?
  15. }
  16.  
  17. }
  18.  
  19. Class<?> cl=new Object(){}.getClass().getEnclosingClass();
  20.  
  21. static class Bar {
  22. public static void main(String[] args) {
  23. Class<?> cl=new Object(){}.getClass().getEnclosingClass();
  24. System.out.println(cl==Bar.class); //will print true
  25. }
  26. }
  27.  
  28. Interface foo = new FooImpl();
  29. foo.getClass(); // returns Class<FooImpl> because the runtime type is FooImpl.
  30. // If getClass() was static, it would return Class<Foo>.
  31.  
  32. static Logger logger = LoggerFactory.getLogger(); // auto detect caller class
Add Comment
Please, Sign In to add comment