如何打破' while'环

时间:2018-01-02 15:50:52

标签: python-3.6

我想在用户输入Y后结束程序。我放了休息 在打印之后,但它并没有打破循环并仍然返回 输入。我该如何打破循环?

   class JuniorInstructor extends Instructor {

    public JuniorInstructor(String id, String name) {
        super(id, name);

    }

}

class Public<T> {
    T object;
    JuniorInstructor j1;
    SeniorInstructor s1;

    public void check(T object) {

        this.object = object;
        if (object instanceof SeniorInstructor) {
            s1 = (SeniorInstructor) object;
            System.out.println("name: " + s1.name + "\tid: " + s1.id);
        } else {
            j1 = (JuniorInstructor) object;
            System.out.println("name: " + j1.name + "\tid: " + j1.id);
        }
    }// check
}
public static void main(String[] args) {
        SeniorInstructor s1 = new SeniorInstructor("120", "Ashik");
        JuniorInstructor j1 = new JuniorInstructor("677", "Tareq");
        Public p = new Public();

        p.check(j1);

    }

1 个答案:

答案 0 :(得分:0)

您输入的代码确实有效。确保输入大写的Y.不是小写,因为它区分大小写。