Java Static Initializer Block

  • + 0 comments

    static int B; static int H; static boolean flag;

    static { Scanner sc = new Scanner(System.in); B = sc.nextInt(); H = sc.nextInt(); if (B > 0 && H > 0) { flag = true; } else{ flag = false; System.out.println("java.lang.Exceptiom: Breadth and height must be positive "); } }