| Home | Links |

Print Slow

  • allows you to print text across the screen at a slower than normal computer speed rate
  • Just copy and paste the method below into the bottom of program so it can be called when ever it is needed
  • To have two different speeds of text printing, copy and paste the code twice and change the name of the method and the speed, and call the methods accordingly

public class SlowPrint
{

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)

{

;

}

}

}

}