从pojo列表中获取元素值

发布于 2025-01-25 15:36:52 字数 467 浏览 2 评论 0原文

我有以下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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一曲琵琶半遮面シ 2025-02-01 15:36:53

首先转到第三元素,

然后转到要访问的特定字段。

在这种情况下。它将是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()

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文