繁体   English   中英

Java while循环不想停止

[英]Java while loop doesn't want stop

我正在学习Java编程,并且对此代码有疑问。 我的问题是我无法停止第二个while循环( while (done ==1){ .. }

如果我完成= 2,程序将恢复...

int stopme3 = 1;
while (stopme3 == 1) {        
    /* Appel de la méthode Afficher les propriétaires */
    AfficherProprio();
    int choix_proprio = ChoisirProprio();

    /* Appel de la méthode Afficher les Comptes du Propriétaire */
    AfficherComptesProprietaire(choix_proprio);

    /* Choix du compte à modifier */
    System.out.println("N° de compte:");
    int choixCompte = lectureClavier.nextInt();
    /* Test si comptes existants du proprio */
    if (choixCompte == tab_compte[choix_proprio]._num_compte) {
        int done = 1;
        while (done == 1) {
            /* Création d'une ligne comptable */
            tab_compte[choix_proprio].CreerLigneC();
            System.out.println("Ajouter une ligne comptable supplémentaire ?");
            System.out.println("1 - Oui");
            System.out.println("2 - Non");
            done = lectureClavier.nextInt();
        }
    } else {
        System.out.println("Compte sélectionné inexistant.");
    }
}

非常感谢您的帮助,非常感谢。

int stopme3 = 1;
            while (stopme3 == 1) { // This loop will keep running till condition is true


int done = 1;
    while (done == 1) {// This loop will keep running till condition is true

因此,它将无限运行。 因此,您可能想这样做

  int stopme3 = 1;
  while (stopme3 == 1) { 

   if(some condition is met){
           stopme3  =2;
       }

}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM