Java - Write code to upper case First Letter and handle null value

Requirements

Write code to upper case First letter

Demo

//package com.book2s;

public class Main {
    public static void main(String[] argv) {
        String texto = "book2s.com";
        System.out.println(upperFirstWord(texto));
    }//from   www .j  ava2 s  . co  m

    public static String upperFirstWord(String texto) {
        String retorno = null;
        if (texto != null && texto.length() > 1) {
            String resto = texto.substring(1);
            String first = texto.substring(0, 1);
            retorno = first.toUpperCase().concat(resto);
        } else if (texto != null && texto.length() == 1) {
            retorno = texto.toUpperCase();
        }
        return retorno;
    }
}