index | value | string to append |
---|---|---|
0 | "english" | "english, " |
1 | "math" | "math, " |
2 | "philosophy" | "philosophy, " |
3 | "computer science" | "and computer science" |
Junilu Lacar wrote:No. Again, what's the point of using a for loop if you're only interested in one element? Pulling out the last element is done only ONE time. *Calculate* the index of the last element, (it's relative to the size of the list), then GET it out of the list and add it to your StringBuilder. Then add the last part of the string to the StringBuilder and you're done. Only thing left to do is display what's in the StringBuilder.
rick pine wrote:So i need to do something n times to the elements on the list, that something its add a comma in between, except for the last element. this is why i used the departments.size()-1 on the first loop. and added a comma, also on this loop im adding the content produced to my sb. ...
You might use that technique to monitor the progress of the adding of Strings and remove the println statements later.Junilu Lacar wrote:. . . go through a stack of cards to show a message and each card has a part of the whole message written on it. . . .
What's wrong with Oxford commas?Paul Clapham wrote:. . . "Oxford Comma" . . . violence among professional editors . . .
It is only easy for us because we aren't doing it. We all faced things just as difficult for us when we were students. The stop coding advice was given because coding is an effective way to make a hard task really difficult.rick pine wrote:im going to follow the "stop coding advice", i know it seems like an easy task for you guys but im struggling and need to cool off.
Campbell Ritchie wrote:We all faced things just as difficult for us when we were students.
Consider Paul's rocket mass heater. |