Break DO While Loop Java?

前端 未结 3 1034
心在旅途
心在旅途 2020-12-10 16:10

I\'m new into JAVA and I\'m not sure how to break a the DO WHILE loop that I use in my code below? I thought I could enter -1 to break or all other numbers to continue the l

3条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 16:32

    You can use break:

    while (true) {
        ...
        if ("-1".equals(value)) {
            break;
        }
        ...
    }
    

提交回复
热议问题