Here you can find the source of toUpperCase(final String s)
Parameter | Description |
---|---|
s | The string for which to retrieve the uppercase version. |
public static String toUpperCase(final String s)
//package com.java2s; /*//w ww . ja va 2s .c om * Copyright (C) 2008-2018 Ping Identity Corporation * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License (GPLv2 only) * or the terms of the GNU Lesser General Public License (LGPLv2.1 only) * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, see <http://www.gnu.org/licenses>. */ public class Main { /** * Retrieves an all-uppercase version of the provided string. * * @param s The string for which to retrieve the uppercase version. * * @return An all-uppercase version of the provided string. */ public static String toUpperCase(final String s) { if (s == null) { return null; } final int length = s.length(); final char[] charArray = s.toCharArray(); for (int i = 0; i < length; i++) { switch (charArray[i]) { case 'a': charArray[i] = 'A'; break; case 'b': charArray[i] = 'B'; break; case 'c': charArray[i] = 'C'; break; case 'd': charArray[i] = 'D'; break; case 'e': charArray[i] = 'E'; break; case 'f': charArray[i] = 'F'; break; case 'g': charArray[i] = 'G'; break; case 'h': charArray[i] = 'H'; break; case 'i': charArray[i] = 'I'; break; case 'j': charArray[i] = 'J'; break; case 'k': charArray[i] = 'K'; break; case 'l': charArray[i] = 'L'; break; case 'm': charArray[i] = 'M'; break; case 'n': charArray[i] = 'N'; break; case 'o': charArray[i] = 'O'; break; case 'p': charArray[i] = 'P'; break; case 'q': charArray[i] = 'Q'; break; case 'r': charArray[i] = 'R'; break; case 's': charArray[i] = 'S'; break; case 't': charArray[i] = 'T'; break; case 'u': charArray[i] = 'U'; break; case 'v': charArray[i] = 'V'; break; case 'w': charArray[i] = 'W'; break; case 'x': charArray[i] = 'X'; break; case 'y': charArray[i] = 'Y'; break; case 'z': charArray[i] = 'Z'; break; default: if (charArray[i] > 0x7F) { return s.toUpperCase(); } break; } } return new String(charArray); } }