Actually, the essence in question. For example, there is a string
String old = "геннадий"; You need to get the string Gennady, that is, the first character must go up in the register
Option number 1:
String capitalized = old.substring(0, 1).toUpperCase() + old.substring(1).toLowerCase(); Option number 2:
String capitalized = Character.toUpperCase(old.charAt(0)) + old.substring(1).toLowerCase(); Option number 3:
StringBuilder sb = new StringBuilder(old.toLowerCase()); sb.setCharAt(0, Character.toUpperCase(sb.charAt(0))); String capitalized = sb.toString(); Option 4:
String capitalized = WordUtils.capitalize (old);
to capitalize the whole offer, or
String capitalized = StringUtils.capitalize (old);
to capitalize a single word.
Source: https://ru.stackoverflow.com/questions/571165/
All Articles