Slip No 15 Q A

Write a java program to display each alphabet after 2 seconds between ‘a’ to ‘z’.

public class AlphabetDelay {

    public static void main(String[] args) {

        try {
            for (char ch = 'a'; ch <= 'z'; ch++) {
                System.out.println(ch);

                // Pause for 2 seconds (2000 milliseconds)
                Thread.sleep(2000);
            }
        } catch (InterruptedException e) {
            System.out.println("Thread interrupted");
        }
    }
}
Spread the love

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top