Skip to content

Instantly share code, notes, and snippets.

@asd1245dss
Last active February 15, 2017 02:25
Show Gist options
  • Save asd1245dss/e323c70b1d97a1b5b208e54a53a6952c to your computer and use it in GitHub Desktop.
Save asd1245dss/e323c70b1d97a1b5b208e54a53a6952c to your computer and use it in GitHub Desktop.
Constructor Block will always be executed first before constructor method
package com.wpg.demo.jdk8.stream;
import java.util.Arrays;
/**
* @author ChangWei Li
* @version 2017-02-15 10:14
*/
class NoMoreLoop {
{
System.out.println("Constructor block 1");
}
public NoMoreLoop() {
System.out.println("Constructor Method");
}
{
System.out.println("Constructor block 2");
}
private static int[] nums = {0, 1, 2, 3, 4, 5};
static void forEach() {
Arrays.stream(nums).forEach(System.out::println);
}
public static void main(String[] args) {
new NoMoreLoop();
new NoMoreLoop();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment