从pojo列表中获取元素值
我有以下Pojo。
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Notas {
private int id;
private String name;
private Long delta;
}
我在pojo中创建了新的索引。
private static final List<Notas> arrayNotas = new ArrayList<>();
arrayNotas.add(new Notas(1,"John",20L));
arrayNotas.add(new Notas(2,"Carol",40L));
arrayNotas.add(new Notas(3,"Peter",30L));
创建后,如何访问任何索引元素?我如何能够从第三行访问第三元素?
I have the following POJO.
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Notas {
private int id;
private String name;
private Long delta;
}
And I create new indexes in the POJO my adding it.
private static final List<Notas> arrayNotas = new ArrayList<>();
arrayNotas.add(new Notas(1,"John",20L));
arrayNotas.add(new Notas(2,"Carol",40L));
arrayNotas.add(new Notas(3,"Peter",30L));
How can I have access to any index element once created? How I would be able to access the 3rd element from 3rd row?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先转到第三元素,
然后转到要访问的特定字段。
在这种情况下。它将是
arraynotas.get(2).getDelta()
First go to the 3rd element,
then go the specific field that you want to access.
in this case. it would be
arrayNotas.get(2).getDelta()