Here you can find the source of toUpperCase(String text)
Parameter | Description |
---|---|
text | a parameter |
public static String toUpperCase(String text)
//package com.java2s; //License from project: Apache License public class Main { /**/*w w w . ja v a 2s . c o m*/ * to upper case like XXX_XXX_XXX * * @param text * @return */ public static String toUpperCase(String text) { if (text != null && text.length() > 0) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < text.length(); i++) { char c = text.charAt(i); if (i != 0 && Character.isUpperCase(c)) { sb.append("_"); } sb.append(Character.toUpperCase(c)); } return sb.toString(); } return text; } }