質問

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?

役に立ちましたか?

解決

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)

他のヒント

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top