I have four binary string stored in an array:     I want to randomly change one bit of the String in each array. From 0 to 1 or 1 to 0. Is there an easy way to change one bit in a string? Thank you for any help.
I need more help!
Joined: Aug 20, 2001
Assuming that I am reading your question correctly, you are stating that you have an array containg four strings:
To answer your question: You can't. Strings are immutable objects; that means, once assigned a value, they cannot change. Do not fear, however! Java is not a language that would leave you hanging like that. Use the StringBuffer class -- it is mutable.
(If you can follow how that bit of code works, then you're doing well....)
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Joined: Sep 11, 2003
Thanks for the help that worked perfectly. Do you know if you can create an array of stringbuffers?