modifed demo.java to print