Java Program to display each character of given string with a delay of 100 ms using Thread

Write a Java program to input a string and print each character from that separately on screen with a delay of 100 ms after each character.



Source Code
import java.util.Scanner;

public class PrintCharWithDelay {

	public static void main(String[] args) {

		Scanner s = new Scanner(System.in);
		System.out.print("Enter the string :: ");
		String str = s.nextLine();
		
		for(int i=0; i<str.length(); i++) {
			System.out.println(str.charAt(i));
			try {
				Thread.sleep(100);
			} 
			catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}

}
Output
Enter the string :: Rahul
R
a
h
u
l