Converting Surender Kumar Sharma to S.K Sharma

1 view
Skip to first unread message

PUNEET KUMAR

unread,
Mar 26, 2013, 5:33:36 AM3/26/13
to ig mc
package javaapplication30;

/**
 *
 * @author puneet
 */
public class JavaApplication30 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        String name ="Salman Khan Hyder"; //Name for conversion

   String[] nameSplit = name.split(" ");//Split name into parts
   int len = nameSplit.length; //get total number of words  in the name 
   String initials = "";
      for(int i = 0; i < len-1; i++)     //get initials from all words except last word
   {
     initials = initials +  nameSplit[i].substring(0,1).toUpperCase() + ". ";
     
   }   
   initials = initials +  nameSplit[len-1]; //print initials along with last word
  
   System.out.println ("Initials Are " + initials);
    }
}
Reply all
Reply to author
Forward
0 new messages