Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
ToCapitalizeCase.java
//*******************************************************************
// Welcome to CompileJava!
// If you experience any issues, please contact us ('More Info') -->
// Also, sorry that the "Paste" feature no longer works! GitHub broke
// this (so we'll switch to a new provider): https://blog.github.com\
// /2018-02-18-deprecation-notice-removing-anonymous-gist-creation/
//*******************************************************************
import java.lang.Math; // headers MUST be above the first class
import java.util.Locale;
// one class needs to have a main() method
public class HelloWorld
{
// arguments are passed using the text field below this editor
public static void main(String[] args)
{
Test myObject = new Test();
String str = myObject.toCapitalizeCase("KÜRŞAT ŞIMŞET IZGARA KÖFTE ŞİŞKEBAB");
System.out.print(str);
}
}
// you can add other public classes to this editor in any order
class Test {
public String toCapitalizeCase(String str) {
Locale tr = Locale.forLanguageTag("tr-TR");
if (str == null)
return "";
str = str.toLowerCase(tr);
String[] spaces = str.split(" ");
for (int i = 0; i < spaces.length; i++)
{
String firstChar = Character.toString(spaces[i].charAt(0)).toUpperCase(tr);
spaces[i] = firstChar + spaces[i].toString().substring(1, spaces[i].length());
}
str = String.join(" ", spaces);
return str;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment