Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to upper case every first letter of word in a string? [duplicate]

Tags:

java

string

I have a string: "hello good old world" and i want to upper case every first letter of every word, not the whole string with .toUpperCase(). Is there an existing java helper which does the job?

like image 423
Chris Avatar asked Jul 19 '09 13:07

Chris


People also ask

How do I make the first letter of each word capital in Excel?

In cell B2, type =PROPER(A2), then press Enter. This formula converts the name in cell A2 from uppercase to proper case. To convert the text to lowercase, type =LOWER(A2) instead. Use =UPPER(A2) in cases where you need to convert text to uppercase, replacing A2 with the appropriate cell reference.

How do you capitalize all words in a string in word?

We can capitalize each word of a string by the help of split() and substring() methods. By the help of split("\\s") method, we can get all words in an array. To get the first character, we can use substring() or charAt() method.

Which method is used to change the first letter of a string to uppercase?

Following are the ways: toUpperCase(): This function applies on a string and change the all letters to uppercase. Return Value: This function returns the capitalized string.


1 Answers

Have a look at ACL WordUtils.

WordUtils.capitalize("your string") == "Your String" 
like image 99
akarnokd Avatar answered Sep 22 '22 21:09

akarnokd