java - 将arraylist的第一个元素分配给另一个arraylist
问题描述
如何从另一个类中获取 ArrayList 的第一个元素并将其分配给另一个 ArrayList?
public class PaymentScreenController {
public ListView<Customer> lvCustomer1;
public ArrayList<Customer> allcustomers;
public ArrayList<Customer> cusarray;
private Table tbl = new Table();
@FXML
public void initialize() {
allcustomers = tbl.getCustomers();
// Getting first element from 'allcustomers and assigning it to cusarray?
// I have tried cusarray = allcustomers.get(0) but that doesn't work?
}
}
然后将 cus 数组分配给列表视图?
任何帮助将不胜感激谢谢
解决方案
尝试:
cusarray.add(allcustomers.get(0));
推荐阅读
- angular - 使用 webpack 为 Angular 6 项目缩小多个 css 文件
- javascript - 关闭浏览器时 Javascript cookie 被删除
- nlp - 了解 Doc2Vec 中函数 build_vocab 的作用
- python - python functools.singledispatch 是否适用于 Generator 类型?
- arrays - 算法的优化 Python 循环
- spring - 在 spring-cloud-gateway 中动态更改 uri() 方法的值
- c++ - OpenGL 纹理几乎不可见(非常暗)
- jupyter-notebook - sympy dsolve 在 google colab 和 jupyter notebook 中给出不同的结果
- node.js - 如何断言 Express app.use 是用中间件函数调用的?(摩卡)
- python - 使用 statsmodels 约束 OLS(或 WLS)系数