SHARE
TWEET

Java object creation

DulcetAirman Apr 12th, 2016 (edited) 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package ch.fhnw.claudemartin;
  2.  
  3. import java.util.function.IntBinaryOperator;
  4.  
  5. public class SomeClass {
  6.   static {
  7.     System.out.println("SomeClass: static initializer block");
  8.   }
  9.   {
  10.     System.out.println("SomeClass: initializer block (non-static)");
  11.   }
  12.  
  13.   int i = ((IntBinaryOperator) ((a, b) -> {
  14.     System.out.println("SomeClass: lambda expression");
  15.     return a + b;
  16.   })).applyAsInt(15, 27);
  17.  
  18.   public SomeClass() {
  19.     super();// super ct'r before the following code!
  20.     System.out.println("SomeClass: constructor");
  21.   }
  22.  
  23.   public static void main(final String[] args) {
  24.     System.out.println("SomeClass: start");
  25.     new SomeClass();
  26.     new InnerClass();
  27.     System.out.println("SomeClass: end");
  28.   }
  29.  
  30.   public static class InnerClass extends SomeClass {
  31.     static {
  32.       System.out.println("InnerClass: static initializer block");
  33.     }
  34.     {
  35.       System.out.println("InnerClass: initializer block (non-static)");
  36.     }
  37.  
  38.     int i = ((IntBinaryOperator) ((a, b) -> {
  39.       System.out.println("InnerClass: lambda expression");
  40.       return a + b;
  41.     })).applyAsInt(24, 67);
  42.  
  43.     public InnerClass() {
  44.       super();// super ct'r before the following code!
  45.       System.out.println("InnerClass: constructor");
  46.     }
  47.  
  48.   }
  49. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top