Hi I currently have a piece of code to append line numbers to a
String, shown below, however I feel it is a bit over complex and messy and wondered if anyone knew of a more efficient way that this could be done. Specifically the formatWithNumbers method, the way that the strings are composed cannot be altered.
AtomicInteger is used as the method can be called by many threads.
The output produced must be:
1|This is the first line
2|This is the second line
3|This is the third line
4|This is the fourth line