我刚接触JAVA,不确定如何中断下面代码中使用的DO WHILE循环。我以为我可以输入-1来中断,或者输入其他数字来继续循环。
import javax.swing.*;
public class Triangel {
public static void main(String[] args) {
int control = 1;
while (control == 1){
String value = JOptionPane.showInputDialog("Enter a number or -1 to stop");
if(value == "-1"){
control = 0;
}
System.out.println(value);
}
}
}