You are viewing a single comment's thread. Return to all comments →
static int B; static int H; static boolean flag=true; static { Scanner sc=new Scanner(System.in); B=sc.nextInt(); sc.nextLine(); H=sc.nextInt(); sc.close(); while(H<=0 || B<=0) { flag = false;
System.out.println("java.lang.Exception: Breadth and height must be positive"); break; }
}
This is more easy and working well.
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 int B; static int H; static boolean flag=true; static { Scanner sc=new Scanner(System.in); B=sc.nextInt(); sc.nextLine(); H=sc.nextInt(); sc.close(); while(H<=0 || B<=0) { flag = false;
}
This is more easy and working well.