Tuesday, 21 April 2020

Special words in Java Programming



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 : 
https://www.youtube.com/channel/UCxV1D-De5EP1P1-vGaPFAQw/videos?view_as=subscriber

No comments:

Post a Comment