Advertisements
Advertisements
Question
Write a program in Java to input a character. Display next 5 characters.
Answer in Brief
Solution
import java.util.*;
public class Q2
{
public static void main(String args[])
{Scanner in = new Scanner(System.in);
char ch;
System.out.println("Enter a character");
ch = in.next().charAt(0);
for (int i = ch + 1; i <= ch + 5; i++)
System.out.println((char) i);
}}
shaalaa.com
Is there an error in this question or solution?
Chapter 2: Library Classes - EXERCISES [Page 179]