Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Finding dollar signs in strings

807607Nov 22 2006 — edited Nov 23 2006
I have a simple program here, not nearly done, that I need a bit of help with.

Basically, the goal of the block of program that I need help with is to scan a string character by character, searching for a dollar sign. If a dollar sign is found, the program is supposed to scan ahead to the next dollar sign, appending the substring between them to another string.

How do I take what is inside the two dollar signs and add it to the new string?
    //_-_-_The getWords Method
    //This method gets words from the user and adds them to the final string.

    static String getWords (String story){

	String newStory = ""; 

	for(i=0; i<story.length(); i++){
	    
	    if(story.charAt(i) = '$')
		newStory = newStory + story.charAt(i);

             else ( This is Where I am Stuck
	
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 21 2006
Added on Nov 22 2006
9 comments
777 views