public static void main (String args[])
{
new SlowPrint ();
}
public SlowPrint ()
{
printSlow ("Hello! \n\n");
//printSlow method is
called here
printSlow ("How are you? \n");
System.out.print ("I am fine. ");
//notice the line build up when you run it
System.out.println ("And you? ");
//notice the automatic line seperation
when you run it
printSlow ("I am good. ");
//printSlow works like system.out.print
//need a line seperator(\n) to produce complete
line of output
//otherwise lines will keep building up
printSlow ("\n\n G O O D B Y E ");
}
//this
is the method that is called above
//put this method at the bottom of your code
public void printSlow (String s)
//when calling the method, use the name declared here
{
for (int i = 0 ; i < s.length () ; i++)
{
System.out.print ("" + s.charAt (i));
//sleep for a bit after printing a letter try
{
//number ‘100' here refers to how long the executing
thread should sleep, in milliseconds
Thread.sleep (100);
//change the speed
//small # = fast
//large # = slow
}
catch (InterruptedException m)
{
;
}
}
}