convert First Char To Lower Case - Java java.lang

Java examples for java.lang:String Case

Introduction

The following code shows how to convert First Char To Lower Case.

Demo Code

//package com.java2s;

public class Main {
    public static void main(String[] argv) {
        String term = "java2s.com";
        System.out.println(convertFirstCharToLowerCase(term));
    }//  ww  w  .j av  a  2  s.c o m

    public static String convertFirstCharToLowerCase(final String term) {
        String convertedString = null;
        int firstHexChar = (int) (term.charAt(0));

        if (firstHexChar > 0x40 && firstHexChar < 0x5B) {
            char[] charsSeq = term.toCharArray();
            charsSeq[0] = (char) (firstHexChar + 0x20);
            convertedString = String.valueOf(charsSeq);
        } else {
            convertedString = term;
        }
        return convertedString;
    }
}

Related Tutorials