You are on the right track with nested loops. I would recommend taking a look at array's next to get your desired result in a compact and dynamic manner.


// It will turn this
String name1;...