Sie sind auf Seite 1von 1

If we want to read line by line, we have to use readLine() method instead of rea d. package com.io; import java.io.

BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class ConsoleString { public static void main(String[] args) { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String s = ""; do { try { s = br.readLine(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println(s); } while(!s.equals("quit")); } } Code Doppler Programming Tutorials: Welcome to Codedoppler Code Doppler Programming Tutorials: Welcome to Codedoppler: Code Doppler is a ne wborn community for newbie to professional developers in JAVA and C++ programmin g languages. Our purpose is to prov... Posted by Nexus Nemesis at 10:05 AM No comments: Links to this post C++ Loops The purpose of loops is to repeat the execution of codes a number of time while the condition is still true. while loop: The form: while(condition) { statement(s); } do while loop: The form: do { statement(s); }while(condition); The difference of the do while is that, it will first execute the statements fir st then check if the condition is still true then if it is still true, it will i terate or loop (executes the statement(s) again).

Das könnte Ihnen auch gefallen