3 / 3
Jan 2011

public class Main {
	public static void main(String[] args) throws Exception {
		 java.io.BufferedReader r = new java.io.BufferedReader (new java.io.InputStreamReader (System.in));
	     String s;
	     while (!(s=r.readLine()).startsWith("42")) System.out.println(s);
	}
}

Can anyone help me with the optimization of this code..it takes 177 M and 0.30 time

And the time here is noted in seconds,milliseconds..?

  • created

    Jan '11
  • last reply

    Jan '11
  • 2

    replies

  • 187

    views

  • 3

    users

Use PrintWriter.

PrintWriter prw = new PrintWriter(System.out, true);
prw.println("Hello World");
13 days later

the time is in sec. 0.30 = 3/10 of a second.

Suggested Topics

Want to read more? Browse other topics in JAVA based languages or view latest topics.