I am trying to get a specific exception
Input H=-1; B=2;
Expected Output
java.lang.Exception: Breadth and height must be positive
Current Output
-2
public class Solution {
static int H,B;
static boolean flag = true;
static //static initializer block
{
Scanner sc = new Scanner(System.in);
H=sc.nextInt();
B=sc.nextInt();
}
public static void main(String[] args){
if(flag){
int area=B*H;
System.out.print(area);
}
}
}
How do I get that specific exception?