Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: Replace Character in String

This example replaces a character with a specified character in a given string.

Tutorial Details:

This example replaces a character with a specified character in a given string.

To replace a character with the given character in sting first convert the string into char array. Use getChars(int scrStart, int scrEnd, char[] destChar, int destStart) method for converting a string into an array of characters. Then use while loop for comparing the "oldChar" ( character name for replace) to be change with the new character of the array. If any match find then replace the "oldChar" with newChar (character name to replace) and set flag =1. To convert charArray into string, pass "charArray" into String class.

getChars(int scrStart, int scrEnd, char[] destChar, int destStart): This method returns an array of characters from a string. We are passing four parameter into this method. First parameter scrStart is the starting point while second parameter scrEnd is the end point of the source string to convert the string into a char array. The destChar is the destined array which stores all the characters. The destStart is starting index to store the characters.


 

Rate Tutorial:
http://roseindia.net/java/beginners/replace.shtml

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
Replace Character in String

View Tutorial:
Replace Character in String

Related Tutorials:

Integrating Databases
Integrating Databases
 
Java decompilers compared - JavaWorld - July 1997
Java decompilers compared - JavaWorld - July 1997
 
StringBuffer versus String - JavaWorld March 2000
StringBuffer versus String - JavaWorld March 2000
 
Tweak your IO performance for faster runtime - JavaWorld November 2000
Tweak your IO performance for faster runtime - JavaWorld November 2000
 
Optimize a query on a Map - JavaWorld November 2000
Optimize a query on a Map - JavaWorld November 2000
 
Design for performance, Part 1: Interfaces matter - JavaWorld January 2001
Design for performance, Part 1: Interfaces matter - JavaWorld January 2001
 
Plant your data in a ternary search tree - JavaWorld February 2001
Plant your data in a ternary search tree - JavaWorld February 2001
 
Design for performance, Part 2: Reduce object creation - JavaWorld February 2001
Design for performance, Part 2: Reduce object creation - JavaWorld February 2001
 
Matchmaking with regular expressions - JavaWorld July 2001
Matchmaking with regular expressions - JavaWorld July 2001
 
Sync up Palm OS with J2ME
Sync up Palm OS with J2ME
 
Quickly access files and directories you use repeatedly
Quickly access files and directories you use repeatedly
 
Java's character and assorted string classes support text-processing
Java's character and assorted string classes support text-processing
 
Sort it out
Sort it out
 
Trustin Lee\'s String/Object Converter - Changes
TL-convert Trustin Lee's String/Object Converter provides a simple API to convert Java objects into strings and vice versa. It is developed to replace Jakarta Commons BeanUtils and Jakarta Commons Convert and to provide only String/Object converters.
 
iCal4j
iCal4j Overview iCal4j is a Java library used to read and write iCalendar data streams as defined in RFC2445. Providing both a parser and an object model, iCal4j allows you to either modify existing iCalendar data or create new data models. Validation
 
JFindReplace
JFindReplace is a "find and replace" swing component working with various options (regulation expression, incremental mode...) and standard text components like JTextArea, JTextPane, JEditorPane....
 
Introduction to JSP tags JSP Directives
Introduction to JSP tags JSP Directives INTRODUCTION TO JSP TAGS I n this lesson we will learn about the various tags available in JSP with suitable examples. In JSP tags can be devided into 4 different types. These are: Directives In the
 
Adding slash "\" character before quote "'" in a query
Adding slash "\" character before quote "'" in a query Adding slash " \ " character before quote " ' " in a query During the inserting the records in the database if user enters the phrases like "What ' s your name?", database gives the error due
 
Welcome! to the News letter archive
Welcome! to the News letter archive News Letter Archive Date Subject Dec-29-2001 Adding slash " \ " character before quote " ' " in a query
 
Connecting to the Database Using JDBC and Pure Java driver
Connecting to the Database Using JDBC and Pure Java driver Connecting to the Database JDBC Driver In our search engine we are using MySQL database server and MM.MySQL Driver for connecting our application to the database. MM.MySQL Driver is
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.