Java String Proper Case toProperCase(String s)

Here you can find the source of toProperCase(String s)

Description

to Proper Case

License

Open Source License

Declaration

static String toProperCase(String s) 

Method Source Code

//package com.java2s;

public class Main {
    static String toProperCase(String s) {
        if (s.length() == 0) {
            return s;
        } else if (s.length() == 1) {
            return s.toUpperCase();
        }/*w  w w .j a v  a2  s  .c o m*/
        // if the remainder is all uppercase, we convert it to lowercase (happens with attrs
        // derived from column names), otherwise we leave the existing camel case
        if (s.substring(1).equals(s.substring(1).toUpperCase())) {
            return s.substring(0, 1).toUpperCase() + s.substring(1).toLowerCase();
        } else {
            return s.substring(0, 1).toUpperCase() + s.substring(1);
        }
    }
}

Related

  1. toProperCase(final String s)
  2. toProperCase(final String string)
  3. toProperCase(String s)
  4. toProperCase(String s)
  5. toProperCase(String s)
  6. toProperCase(String text)
  7. toProperCase(String text)