javaクラスアダプタがあります。これはエラーです(Groceries b:getData())。オブジェクトをGroceries.javaに変換できないため、 B:Groceries.javaエラー:互換性のない型オブジェクトを(Javaクラス)に変換できません
からのgetData())私はb.getProduct(メソッドを呼び出すことはできません)getSn()DataAdapter.java
public Groceries getBelBySN(String sn) {
Groceries pp = null;
for (Groceries b : getData()) {
if (b.getProduct().getSn().equals(sn)) {
pp = b;
break;
}
}
return pp;
}
public void updateTotal() {
long jumlah = 0;
for (Groceries b : getData()) {
jumlah = jumlah + (b.getProduct().getHarga() * b.getQuantity());
}
total = jumlah;
}
は、これは私は、アダプタを呼び出すことGroceries.javaです
public class Groceries {
protected Product product;
protected int quantity;
public Groceries(Product product, int quantity) {
this.product = product;
this.quantity = quantity;
}
public void setProduct(Product product) {
this.product = product;
}
public Product getProduct() {
return product;
}
public void setQuantity(int quantity) {
this.quantity = quantity;
}
public int getQuantity() {
return quantity;
}
'getData()'は何を返しますか? 'getData()'のコードを表示できますか? –
getData()はリストから – Rizal