java - Why is this do-while loop not stopping? -


the purpose of loop stop period key typed, not working , did not understand why.

import java.io.ioexception;   public class controlflowtest {  public static void main(string[] args) throws java.io.ioexception {     char ch ;      do{         ch = (char) system.in.read();     }while(ch != '.');  } 

you want use scanner system.in.read() block until carriage return entered. try this:

import java.io.ioexception;  public class controlflowtest {     public static void main(string[] args) throws java.io.ioexception {         char ch ;          scanner scanner= new scanner(system.in);         {             ch = scanner.next().charat(0);         } while(ch != '.');     } } 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -