Hi, I am new to Java programming language. And I need some help. I want to make a program, that will Capitalize the first letter of each word in input. For example if the input is, "now is the time to act" , the output should be "Now Is The Time To Act". That will be of great help. Also if you can give me a code for a program that will replace a String with another string. For example there should be three inputs. First input should be a sentence. The second input should be a part from words in the first sentence. The third input should be a different word. For example, if the first input is, "I like playing basketball" and the second input is "basketball", and the third input is "soccer". The out put should be, "I like soccer". So it replaces the second input with the third. Can anyone help me plzzzzzzzzz, send replies here, or to my e-mail: firstname.lastname@example.org its urgent plzzzzzzzz Thank you
Hi John Mcrae, As discussed many times in this forum that please don't try to submit your home works and assignment here. Try to write the code yourself and if you face any problem in that then you are welcome to post that here. I am not trying to discourage you but nobody has much time to do you assignments. Anyhow you can use String class's methods to replace the strings and do other functions. like there is substr() function which searches for the specific substring inside the string and return the starting index of that substring. there is also a replace() method. So first see the String class. You can see from http://java.sun.com/j2se/1.4.2/docs/api/java/lang/String.html. After that write the code yourself and if you face any problem regarding that submit your question. You will difinately get an answer.
Joined: May 05, 2004
Thats what I have so far:
I dont know how to save the first word in a separate place and the remainder of word in another. Can you help me here plz z [ edited to preserve formatting using the [code] and [/code] UBB tags -ds ] [ May 06, 2004: Message edited by: Dirk Schreckmann ]
Welcome to JavaRanch, John! As suggested by Ali, you'll likely want to become very comfortable with harvesting all of the great information in the API documentation. You might find a method described in the Character class documentation that converts lower case letters to upper case letters to be useful.