Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Beginning Java
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Tim Cooke
Campbell Ritchie
Ron McLeod
Junilu Lacar
Liutauras Vilda
Sheriffs:
Paul Clapham
Jeanne Boyarsky
Henry Wong
Saloon Keepers:
Tim Moores
Tim Holloway
Stephan van Hulst
Piet Souris
Carey Brown
Bartenders:
Jesse Duncan
Frits Walraven
Mikalai Zaikin
Forum:
Beginning Java
string capitalise
Molefhi Sebaka
Greenhorn
Posts: 1
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
i need help on how to capitalise the first letters in a
string
: example "my name is" to output "My Name Is"
Rusty Shackleford
Ranch Hand
Posts: 490
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
A quick look at the string class methods should tell you what two methods you can use for this.
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/String.html
"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
memati bas
Ranch Hand
Posts: 85
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
public static String convert(String s ) { String line = "", line1 = ""; StringTokenizer tok = new StringTokenizer(s," "); while(tok.hasMoreTokens()){ line1 = ""; String b = tok.nextToken(); for(int a = 0; a < b.length(); a++){ if(a == 0) { line1 += b.charAt(0); line += line1.toUpperCase(); } else line += b.charAt(a); } line += " "; } return line; }
Robert Hill
Ranch Hand
Posts: 94
posted 16 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
StringTokenizer has been deprecated for a long time and should not be used. There is a better alternative in the String class.
Also doing someones homework for them is counter-productive.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Letters with accent
Single thread that runs 5 times, sleeps, then runs 5 more times
Converting a String to Proper Case
Help Tomcat crashing.
splitting a StringBuffer into tokens?
More...