Results 1 to 3 of 3
- 03-26-2009, 06:56 PM #1
Member
- Join Date
- Jan 2009
- Posts
- 24
- Rep Power
- 0
Replacing the chars within a string.
Hello all. What I am trying to do is transpose each letter in a string and putting that string into a new string that will go into a new array.
EDIT: Ok I got it to work but the output is weird now on some of them. I was hoping if someone can explain.
EDIT: REMOVED CODE TO PROTECT MYSELF FROM PEOPLE IN MY CLASS FINDING IT AND COPYING IT. PROFESSOR USES A SCRIPT TO MATCH ANY SIMILARITIES IN CODE TO PREVENT CHEATING.
As you can see the words in bold in the output, the first letter does not go in order.
Any help would be greatly appreciated.Last edited by Mayur; 03-27-2009 at 04:01 AM.
- 03-27-2009, 03:53 AM #2
Check the Method Detail for the replace method in the String api.
It replaces all instances of oldChar with newChar.Java Code:String replace(char oldChar, char newChar)
Java Code://theTrWord = theTrWord.replace(theTrWord.charAt(c2), // transLetter); theTrWord = theTrWord.substring(0, c2) + String.valueOf(transLetter) + theTrWord.substring(c2+1);
- 03-27-2009, 04:00 AM #3
Member
- Join Date
- Jan 2009
- Posts
- 24
- Rep Power
- 0
Similar Threads
-
replacing backslashes in String Object
By nishiz in forum Advanced JavaReplies: 9Last Post: 12-02-2010, 12:31 AM -
Help Replacing String
By 7oclock in forum New To JavaReplies: 5Last Post: 02-14-2009, 07:31 AM -
How to print chars with symbols from a string
By blacksky in forum New To JavaReplies: 23Last Post: 01-06-2009, 01:14 PM -
replacing last comma in a string with the word "or"
By wprjr in forum New To JavaReplies: 1Last Post: 05-07-2008, 01:19 AM -
splitting string and replacing
By itsme in forum New To JavaReplies: 1Last Post: 12-11-2007, 03:08 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks