Results 1 to 3 of 3
Thread: Using a replace method...
- 07-16-2007, 04:02 PM #1
Member
- Join Date
- Jul 2007
- Posts
- 26
- Rep Power
- 0
- 07-16-2007, 04:09 PM #2
Please explain more clearly. I did not understand what you want to do..
- 08-07-2007, 04:50 AM #3
Member
- Join Date
- Jul 2007
- Posts
- 39
- Rep Power
- 0
I don't quite understand your question, but I'll give some advice.
If my code above is syntactically correct, that will replace all letters in "word" with *. But since you've changed "hello" to "*****" you've lost the secret word completely. Maybe you want something like...Java Code:String word = hello; for(int i = 0; i < word.length; i++) { word.replace(word[i], "*"); }
Now both the above use for-loops not while-loops, but they are essentially the same. Why is it that you can't use a while-loop?Java Code:String word = hello; String coverUpWord = ''; for(int i = 0; i < word.length; i++) { coverUpWord += '*'; }
Greetings.
Similar Threads
-
Find and replace ( in a String
By hamish10101 in forum New To JavaReplies: 6Last Post: 01-17-2008, 05:51 AM -
Find and Replace in JTable
By look4 in forum AWT / SwingReplies: 2Last Post: 11-24-2007, 12:27 AM -
problems with replace method
By cecily in forum New To JavaReplies: 1Last Post: 08-02-2007, 09:11 PM -
String replace method
By venkata.tarigopula in forum Advanced JavaReplies: 1Last Post: 07-10-2007, 08:14 PM -
Using Find And Replace In Eclipse IDE
By JavaForums in forum EclipseReplies: 0Last Post: 04-26-2007, 10:15 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks