You are viewing a single comment's thread. Return to all comments →
static boolean flag = true; static int B,H;
static{ Scanner s=new Scanner(System.in); B=s.nextInt(); s.nextLine(); H=s.nextInt(); s.close(); if(H<=0 || B<=0){ flag=false; System.out.println("java.lang.Exception: Breadth and height must be positive"); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Java Static Initializer Block
You are viewing a single comment's thread. Return to all comments →
static boolean flag = true; static int B,H;
static{ Scanner s=new Scanner(System.in); B=s.nextInt(); s.nextLine(); H=s.nextInt(); s.close(); if(H<=0 || B<=0){ flag=false; System.out.println("java.lang.Exception: Breadth and height must be positive"); } }