Java String Title Case toTitleCase(String string)

Here you can find the source of toTitleCase(String string)

Description

to Title Case

License

LGPL

Declaration

public static String toTitleCase(String string) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    public static String toTitleCase(String string) {
        String result = "";

        for (int i = 0; i < string.length(); i++) {
            String next = string.substring(i, i + 1);
            if (i == 0) {
                result += next.toUpperCase();
            } else {
                result += next.toLowerCase();
            }//from w  w  w. j a v a2s  . c  o  m
        }
        return result;
    }
}

Related

  1. toTitleCase(String s)
  2. toTitleCase(String sIn)
  3. toTitleCase(String str)
  4. toTitleCase(String str)
  5. toTitleCase(String string)
  6. toTitleCase(String text)
  7. toTitleCase(String title)
  8. toTitleCase2(String string, String separators)
  9. toTitleCaseIdentifier(String formStr)