为了创建具有唯一 ID 的客户端对象,我正在考虑这样做(见下文)。是否会为这个新创建的对象分配一个随机生成的字符串并添加到对象中,然后添加到列表中?我以后可以访问它吗?(抱歉无能)。
目前还没有测试的方法。
List<Client> newCli = new ArrayList<Client>();
String uniqueID = UUID.randomUUID().toString();
Client Client = new Client(name1, name2, addrName, addrNumber, post, city, uniqueID);
newCli.add(Client);
客户端指的是带有变量的类和带有参数的构造函数,如下所示。
非常感谢!