convert all But First Char To Lower Case - Java java.lang

Java examples for java.lang:String Case

Introduction

The following code shows how to all But 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(allButFirstCharToLowerCase(term));
    }//  ww w.jav a2  s  . co  m

    public static String allButFirstCharToLowerCase(final String term) {
        String convertedString = null;
        int hexChar = -1;
        char[] charsSeq = null;

        /*
         * If this is a upper case, convert to lower case.
         */
        for (int k = 1; k < term.length(); k++) {
            hexChar = (int) (term.charAt(k));
            if (hexChar > 0x40 && hexChar < 0x5B) {
                if (charsSeq == null) {
                    charsSeq = term.toCharArray();
                }
                charsSeq[k] = (char) (hexChar + 0x20);
            }
        }

        if (charsSeq != null) {
            convertedString = String.valueOf(charsSeq);
        }

        return convertedString;

    }
}

Related Tutorials