Maybe you should write a function that takes two parameters- a String, and an int. The function returns the String value of the character at that position. You already do that.
When you have that...
Type: Posts; User: KevinWorkman
Maybe you should write a function that takes two parameters- a String, and an int. The function returns the String value of the character at that position. You already do that.
When you have that...
Okay, and what does that output?
Take a look at the String API: String (Java Platform SE 6)
Pay special attention to the different substring() methods. See the one that takes two arguments, a...
You already have the syntax though. You already use the substring() method. I don't understand what you're stuck on. Make an attempt and post what you have instead of giving up and crossposting.
Nevermind, I guess I'm wasting my time here.
http://www.java-forums.org/new-java/49066-dont-know-how-use-lastindexof.html
You already use the subString() method. That's one way to get the character at a certain location. Have you tried that?
You aren't incorrectly using int, you're just not taking the next step. You have the position of the character you want. Now you need a method that gets that character. Hint: You're already using one...
Why are you using the indexOf() method? More accurately, why are you simply printing out the value returned from it? That gives you the position of the space, but that's not what you want to print...
The API is your best friend: String (Java Platform SE 6)
Java Platform SE 6
There are quite a few ways to do this. You could split on spaces or iterate over each char, testing whether each is an initial (what that means is up to you). Check out the API for useful methods.
What have you tried? Where are you stuck?