Well, personally, I would do it like this:
public class Client { private String name; private String phone; public Client(String name, String phone) { this.name = name; this.phone = phone; } // Getters ans setters } public class DataClients { private boolean status; private String message; private List<Client> clients; public DataClients(boolean status, String message, List<Client> clients) { this.status = status; this.message = message; this.clients = clients; } // getters and setters }
And then one could do something like this:
List<Client> clients = new ArrayList<>(); clients.add(new Client("Vasya", "123")); clients.add(new Client("Anna", "222")); clients.add(new Client("John", "300")); DataClients dataClients = new DataClients(true, "message", clients);
This approach will be more understandable for other programmers than to use the data collection that is incomprehensible to anyone in the array. It would also be possible to fasten the "Builder" pattern for DataClients, but this is optional ...