I have an ArrayList of strings, and I want to randomly change a string’s (random) char’ by index.
ArrayListName.get(i).charAt(j)
exists. What’s the equiv’ for a setter?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Strings are immutable so they can’t change. You can use a
StringBufferorCharacter Array.StringBufferhas asetCharAtmethod that takes an index and character.If you want to use a
Stringyou’ll have to create a newStringwith the character changed and replace the oldString.