I am wondering that why Character.toUpperCase/toLowerCase has no Locale parameter like String.toUpperCase/toLowerCase.
I have to first uppercase of a text that can be in Any language. I have 2 solutions:
Use
Character.toUpperCaseString text = "stack overflow"; StringBuilder sb = new StringBuilder(text); sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); // No Locale parameter here. String out = sb.toString(); //Out: Stack overflowUse
String.toUpperCaseLocale myLocale = new Locale(locateId); String text = "stack overflow"; String text1 = text.substring(0,1).toUpperCase(myLocale ); String text2 = text.substring(1); String out = text1 + text2; // Out: Stack overflow
For my Locale. Both way has the same result.
My question is:
Since the text can be in any language. Which way should I use?
Why
Character.toUpperCase/toLowerCasehas no Locale parameter because there is not much difference betweenCharacter.toUpperCase/toLowerCaseandString.toUpperCase/toLowerCasebecause String is array of Characters.