I don't understand the complexity & usecase. However, you can certainly use the conditions at the start of the loop where you are building an array and at the last to not include the ",". In sling model, you have the control and you can easily use the core java features & add some logic to meet your...