June 30th, 2003, 11:04 AM
I want to take a string, and capitalize the first letter.
How would I do that?
June 30th, 2003, 02:53 PM
Look at String.toUpperCase() and/or Character.toUpperCase(). you could use these in conjunction with String.substring() and String.indexOf() or maybe String.toCharArray().
June 30th, 2003, 03:14 PM
What are their arguments?
Also, what would you call String.toUppercase? a method? function? object?
I'm still new to the terminology, and I didn't find any of those above in my jsp books. (Mostly cause i didn't know where too look.)
June 30th, 2003, 05:01 PM
Bookmark this link. It is the API javadocs. You will use this more than any book.
Scroll down on the left to find the Character class and the String class. When you click on these, all the constructors and methods will show in the main frame.
String is a class. Character is a class. When you make a new one (ex: String str = "this is a string") it is called an object. What I told you to use were methods. They are called methods in Java, not functions, though they are essentially the same thing and I continually use the terms interchangeably.
Could you show me some example code?
That page doesn't have any examples, so it's quite hard for me to understand at this point
that just gives "cannon resolve symbol"
num = String.toUppercase("num");
No offense, but this is getting into java fundamentals. I would suggest a beginning java tutorial. A search on google should turn up many results.
To answer your question, toUpperCase is not a static method and therefore needs to be called on a valid String object. Something like this would work:
Assuming num is a String object.
num = num.toUppercase("num");
This will all become clearer if you learn some fundamentals.
EDIT: here is a tutorial off of Suns site
Last edited by Nemi; July 1st, 2003 at 03:26 PM.
num = "num".toUpperCase() will also work. num would be equal to "Num".
Steven, since you're getting into jsp, you should probably also bookmark the j2ee javadocs: http://java.sun.com/j2ee/sdk_1.3/techdocs/api/
It takes awhile to get comfortable using/browsing a javadoc, but once you've used it for awhile you'll find the answers to most of your questions there.