Tuesday, 28 April 2020

Special word in Java programming


Special words 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 Scaner(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) ;
        }
    }
}


For Video visit my YouTube channel :  SK Skill India







3 comments: