java - How can I use "do while" command here? -


i learning java, here's code

import java.util.scanner;   public class application {      public static void main(string[] args) {          scanner input = new scanner(system.in);           system.out.println("enter password");         string value = input.nextline();           if(value.equals("mycat")){             system.out.println("password accepted!");             system.out.println("my personal number is: ");             system.out.println("blahblah");         }         else              system.out.println("incorrect password!");           }       } 

i want keep saying incorrect password , allow enter rather stopping. want looping when ever this, don't results want.

scanner input = new scanner(system.in);  {     system.out.println("enter password");     string value = input.nextline();      if(value.equals("mycat")){         system.out.println("password accepted!");         system.out.println("my personal number is: ");         system.out.println("blahblah");     }     else          system.out.println("incorrect password!"); } while(!value.equals("mycat"))  input.close(); 

enclose code within try-catch block.


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -