(This is for homework but I've been going back through my online textbook which is impossible to check). My code is working correctly except for one issue - I need the String value to have two iterations but can't print the Array list twice.
I used the following code just to make sure it would work correctly:
if (i != myList.size()) { s = ", "; for (i = 0; i < myList.size() - 1; ++i) { System.out.print(myList.get(i) + s); } System.out.print(myList.get(i)); }
But I need it to print like this for one test:
1, 2, 3, 4, 5, 6
And like this for a second:
1 - 2 - 3 - 4 - 5 - 6
I tried using a Scanner but then I get no output so that seems incorrect. I can get one logic test to work but the other fails. Am I missing another way to set s to multiple choices (it's supposed to be a String argument for the method)?
It was recommended to me that I get the loop to run through twice but I can't figure how to and the line can't print twice.