Page 1 of 1

About Question com.enthuware.ets.scjp.v6.2.685 :

Posted: Thu Jul 10, 2014 12:07 am
by sarmadys
This program runs but does not produce any output (not in eclipse, not in command line). Why is that? Furthermore osw serves no purpose.

Code: Select all

public class TestClass
{
  public static void main(String[] args)
  {
     PrintWriter pw = new PrintWriter(System.out);
     OutputStreamWriter osw  =  new OutputStreamWriter( System.out);
     pw.print("hello");
  }
}

Re: About Question com.enthuware.ets.scjp.v6.2.685 :

Posted: Thu Jul 10, 2014 8:11 am
by admin
The purpose of the question is to test you on imports. Output is not important here. But you can get the output if you add a line pw.flush() at the end.

HTH,
Paul.