Java Static Initializer Block

  • + 0 comments

    public class Solution {

    static{
             Scanner in = new Scanner(System.in);
             int b = in.nextInt();
             int h = in.nextInt();
    
             if(b <= 0 || h <= 0){
                System.out.println("java.lang.Exception: Breadth and height must be positive");
             }else{
                int x = b*h;
                System.out.println(x);
             }
        }
    
    public static void main(String[] args) {
    }
    

    }