This program will print each character from a given string with a delay of 100ms.
PROGRAM
PROGRAM
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
C:\>javac PrintCharWithDelay.java C:\>java PrintCharWithDelay Enter the string :: Rahul R a h u l
No comments:
Post a comment