문제

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