Title

JAVA

      In this blog, you will find programs on JAVA and also some help on how to write programs for JAVA...

December 18, 2014

WAP to get the name of a person and print his initials

import java.util.Scanner;
public class Initials
{
    public static void main()
    {
        Scanner s=new Scanner(System.in);
        String str=s.nextLine();
        String a[]=str.split("\\ +");
        String p="";
        for(int x=0; x<a.length; x++)
        {
            char c=a[x].charAt(0);
            p=p+c+".";
        }
        System.out.println(p);
    }
}

No comments:

Post a Comment

Please write your comment in the box below...