Guest User

Untitled

a guest
Dec 9th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. public class Teste {
  2.  
  3. public void doSomething() {
  4. System.out.println("Run");
  5. throw new RuntimeException("Exception handling");
  6. }
  7.  
  8. public void doConsumer(Consumer<Teste> consumer) {
  9. consumer.accept(new Teste());
  10. }
  11.  
  12. public void doRunnable(Runnable func) {
  13. func.run();
  14. }
  15.  
  16. public void fromInside() {
  17. doRunnable(this::doSomething);
  18. doConsumer(Teste::doSomething);
  19. }
  20.  
  21. public static void main(String[] args) {
  22. Teste t = new Teste();
  23. t.fromInside();
  24. }
  25. }
Add Comment
Please, Sign In to add comment