Replace( ) Java Help

Replace( ) 

The replace( ) method replaces all occurrences of one character in the invoking string with character. It has the following general form: String replace(char original, char replacements Here, original specifies the character to be replaced by the character specified by replacement. The resulting string is returned. For example,

String trim 

The trim() method returns a copy of the invoking string from which any leading and trailing white space has been removed. It has this general form: , This puts the string “Hello World” into The trim( ) method is quite useful when you process user commands. For example, the following program prompts the user for the name of a state and then displays that state’s capital. It uses trim() to remove any leading or trailing white space that may have inadvertently been entered by $e user.

JavaHelpOnline.com

  • Feel free to send us an inquiry, we will reply back in hours.
 

Verification

Posted on September 17, 2014 in Staring Handling

Share the Story

About the Author

Back to Top