Special words in Java Programming are those words which start and end with the same letter.
Examples:
EXISTENCE , COMIC , WINDOW
import java.util.Scanner;
class specialWord
{
public static void main(String[] args)
{
Scanner sk = new Scanner(System.in);
System.out.print("Enter word:
");
String wd = sk.next();
char f = wd.charAt(0);
char la = wd.charAt(wd.length()- 1);
if (f == la)
{
System.out.println(" It is a
Special word : " +wd);
}
else
{
System.out.println(" It is Not
a special word : " +wd) ;
}
}
}
Visit My YouTube channel :
No comments:
Post a Comment