0
我有一個填充了-Integer,「Obra」 - 對象散列圖的Jlist,並且我有一個方法可以接收obras列表,我試圖讓所有在JList和嘗試selectd奧夫拉斯傳遞作爲參數傳遞給我的方法,但我不斷收到一個錯誤類型不匹配如何從jlist檢索對象列表
這裏是我的代碼
public class Emprestimo {
private Usuario u;
private Calendar dataRealizacao;
private double total = 0;
public Emprestimo(Usuario u){
this.u = u;
dataRealizacao = Calendar.getInstance();
}
public void realizaEmprestimo(Obra... o){
try{...do stuff
anotherclass
emp = new Emprestimo(user);
emp.realizaEmprestimo(JlistObra.getSelectedValuesList()); // here's where i get my error
我試圖做一個鑄像這樣
(emp.realizaEmprestimo((Obra)JlistObra.getSelectedValuesList());
這
(emp.realizaEmprestimo((Obra[])JlistObra.getSelectedValuesList());
,但它不工作
和我做:
emp.realizaEmprestimo((Obra) JlistObra.getSelectedValue());
其作品,但在我的jList