Basically, (dog)(cat)(mouse) needs to be (dog) (cat) (mouse).
My attempted code:
StringBuilder sb = new StringBuilder("(dog)(cat)(mouse)");
for (int i = 0; i < sb.length(); i ++)
{
if (sb.charAt(i) == ')')
{
sb.insert(i, ' ');
}
}
String result = sb.toString();
But I'm getting some sort of "Java heap space" error
Aucun commentaire:
Enregistrer un commentaire