java help :o

yow,

i need some help for some stuff i have to program for university.
i want to replace one character of a string. is it possible?
if so, could you help me how to implement it?

in detail: i got a String[] containing the rows of an adjacence matrix in which i want to change one value (e.g. 1000 in 1100).

thanx in advance
Comments
3
java gay language :X

you could always split the string into 3 substrings and replace the middle one?

or if its numeric values, just convert it into an integer? :D
well, from what I read you basically described whole algorithm. For replacing one char in string, you can use built String methods which can give access to individual chars (String is basically just array of chars), so just loop over the string and replace values to whatever you need.
Another aproach (and more efficient in bigger scale) would be making use of regular expressions.
for loop through the array

replace the string when current element is the string u want to replace
Back to top