Originally Posted by
helloworld922
@duff
your code is almost right. Instead of setting the String at i to just a single 1 or 0, you have to get the i'th string and then set a specific character to 1 or 0. Here's a version that will work, I bolded the parts that were changed.
for (int i = 0; i < populationArray.size(); i++)
{
for (int j = 0; j < [b]populationArray.get(i).length()[/b]; j++)
{
if (new Random().nextInt(100) == 1)
{
if (populationArray.get[b](i)[/b].charAt(j) == '0')
{
[b] populationArray.get(i).setCharAt(j, '1');[/b]
}
else
{
[b]populationArray.get(i).setCharAt(j, '0');[/b]
}
}
}
}
Ah my bad I didn't notice(or know about) the StringBuilder seems like a handy little class alright. I would go with helloworld on this one seems simple and elegant and probably along the lines you were thinking.