There is a sample given in BruceEckel's book - thinking in Java
It says:
Some programming environments will flash programs up on the screen and close
them before your've had a chance to see the results. u can put in the
following cod eat the end of main() to pause the output:
try{
Thread.currentThread().sleep(5*1000);
}
catch(InterruptedException e){}
}