Question

I'm trying to capitalize the first character of each word in a string in Java. Yes I've done my research, I found this How to capitalize the first character of each word in a string. I've downloaded the binaries but I have no clue how to install them. So how do I install Lang https://commons.apache.org/proper/commons-lang/. Thank you, SQL :P

EDIT: I'm using Eclipse. I wish to use the method capitalizeFully() that is in WordUtils. How would I do this?

Was it helpful?

Solution

Download latest version of Apache Commons Lang commons-lang3-version-bin.zip

Currenly commons-lang3-3.1-bin.zip

Place the jar file commons-lang3-version.jar in your class path and

import org.apache.commons.lang.WordUtils;

in your class

Finally use

WordUtils.capitalize(str) or WordUtils.capitalizeFully(str)

OTHER TIPS

write the code yourself. Look at the java docs for the string class. mystring.charAt(index).toUpperCase

When you got the Space in string using charAt(index) , You can make index+1 char in Capital by charAt(index).toCapital

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top