Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Stanimir Stamenkov Newsgroups: comp.lang.java.programmer Subject: Re: The greeting code in Java Date: Sun, 19 Jun 2011 18:06:23 +0300 Organization: A noiseless patient Spider Lines: 32 Message-ID: References: <3d6aab49-9a4a-4614-af12-bb1c95bebbe7@w4g2000yqm.googlegroups.com> <4dfdf77e$0$4132$426a74cc@news.free.fr> <06cf6f85-5473-47da-b599-de2e7f81976d@d1g2000yqm.googlegroups.com> <4dfe0ce7$0$4853$426a74cc@news.free.fr> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Sun, 19 Jun 2011 15:06:21 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="VdcnnljfizG2LUdZ5iOA6g"; logging-data="3562"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/G2RzM9R9dWeOj+QSvGxdg" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20110618 SeaMonkey/2.2 In-Reply-To: <4dfe0ce7$0$4853$426a74cc@news.free.fr> X-Face: )>>ChyF_H Yes, indeed, i did a mistake. > Replace the .print( with a .println(, othewise output is not flushed and > the greeting appear only after output. No. Your code just prints the prompt after it has got the user input: Sun, 19 Jun 2011 15:19:58 +0200, /Aéris/: > public class Main { > public static void main(final String[] args) throws IOException { > final BufferedReader in = new BufferedReader( > new InputStreamReader(System.in)); > String s; > while ((s = in.readLine()) != null&& s.length()> 0) { > System.out.print("Please enter your first name:"); > System.out.println("Hello, " + s); > } > } > } I guess one needs: System.out.print("Please enter your first name: "); while ((s = in.readLine()) != null && s.length() > 0) { System.out.println("Hello, " + s); System.out.print("Please enter your first name: "); } -- Stanimir