Convert String to Initcap Using Java

 Posted On  | Yashwant Chavan 

Sample code convert input string into init cap letter using java,First we convert the input string into char array. Then convert its first letter to Upper Case.

toInitCap() method


public class InitCapExample {
    public static void main(String[] args) {

    public static String toInitCap(String param) {
        if (param != null && param.length() > 0) {
            char[] charArray = param.toCharArray();
            charArray[0] = Character.toUpperCase(charArray[0]);
            // set capital letter to first position
            return new String(charArray);
            // return desired output
        } else {
            return "";



HTML Comment Box is loading comments...

Hi I am Yashwant Chavan founder of, Purpose of this website to share the programming knowledge in the form post , blogs and articles.

Latest Updates

Stay updated with latest post, articles and technical discussions.

© 2016

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0229 seconds.