Java String Capitalize capitalize(String string)

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

Description

capitalize

License

Apache License

Declaration

public static String capitalize(String string) 

Method Source Code

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

public class Main {
    public static String capitalize(String string) {
        if (string.isEmpty()) {
            return string;
        }/* ww w  .  j a va  2  s.  co  m*/
        if (string.length() == 1) {
            return string.toUpperCase();
        }
        final String first = string.substring(0, 1);
        final String remaining = string.substring(1);
        return first.toUpperCase() + remaining;
    }
}

Related

  1. capitalize(String string)
  2. capitalize(String string)
  3. capitalize(String string)
  4. capitalize(String string)
  5. capitalize(String string)
  6. capitalize(String string)
  7. capitalize(String string)
  8. capitalize(String string)
  9. capitalize(String string)