java 异常调用的问题 无法得到正确的答案

import java.util.Scanner;

class InvalidSideException extends Exception{
    InvalidSideException(String s){
        super(s);
    }
}

class Square{
    int sl;
    public Square(int sl) throws InvalidSideException{
        if (sl <= 0){
            throw new InvalidSideException("Side length must be greater than 0");
        }else{
            this.sl = sl;
        }
    }

    public int getArea(){
        return this.sl * this.sl;
    }
}

public class Driver{
    public static void main(String[] args){
        System.out.print("Enter side length of square:");
        Scanner s = new Scanner(System.in);
        int x = s.nextInt();

        try{
            Square sq = new Square(x);
            System.out.println(sq.getArea());
        }catch(InvalidSideException e){
            e.printStackTrace();

        }
    }

}

我想得到
Enter·side·length·of·square:0
Enter◦side◦length◦of◦square:Side◦length◦must◦be◦greater◦than◦0.
但是
结果总是
Enter◦side◦length◦of◦square:
无法打印Side◦length◦must◦be◦greater◦than◦0.
求问怎么diao'yong

那是因为你没有输入0,程序并没有往下执行,你可以打印x看看有没有值,执行后应该类似如下所示:
图片说明