I assigned a string by for loop to an arrayList but when printing the result it will print each index twice, I solve this problem by modifying for loop to increase by.
for (int i = 0, i< x.getLength() ;i++)
{
Node child = children.item(i );
{
name = child.getNodeNa me()
}
myArrayList.add (name)
}
for (int s = 0, s< x myArrayList.siz e() ;s = s + 2 )
System.out.prin tln(myArrayList (y)); // Printing twice
}
for (int i = 0, i< x.getLength() ;i++)
{
Node child = children.item(i );
{
name = child.getNodeNa me()
}
myArrayList.add (name)
}
for (int s = 0, s< x myArrayList.siz e() ;s = s + 2 )
System.out.prin tln(myArrayList (y)); // Printing twice
}
Comment