Java Static Initializer Block
문제 확인하기
static boolean flag;
static int B;
static int H;
static {
Scanner scanner = new Scanner(System.in);
B = scanner.nextInt();
H = scanner.nextInt();
if (B > 0 && H > 0) {
flag = true;
} else {
System.out.println("java.lang.Exception: 너비와 높이는 양수여야 합니다.");
flag = false;
}
scanner.close();
}
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
static boolean flag;
static int B;
static int H;
static {
Scanner scanner = new Scanner(System.in);
B = scanner.nextInt();
H = scanner.nextInt();
if (B > 0 && H > 0) {
flag = true;
} else {
System.out.println("java.lang.Exception: 너비와 높이는 양수여야 합니다.");
flag = false;
}
scanner.close();
}
public static void main(String[] args){
if(flag){
int area = B * H;
System.out.print(area);
}
}
}