728x90 자바 초기화 블럭1 [JAVA] ch05-22. 초기화블럭 2 public class Ex22 { public static void main(String[] args){ Product p1 = new Product(); Product p2 = new Product(); Product p3 = new Product(); System.out.printf("p1: %d\n",p1.serialNo); System.out.printf("p2: %d\n",p2.serialNo); System.out.printf("p3: %d\n",p3.serialNo); System.out.printf("Total: %d", Product.count); } } class Product{ static int count = 0; int serialNo; { serialNo = ++count; /.. JAVA/예제 2017. 8. 22. 이전 1 다음 728x90