Java
1import java.io.*; 2import java.util.*; 3 4public class Main{ 5 6 public static void main(String[] args) throws IOException { 7 8 Item iList01 = new Item("01","desk",5000); 9 Item iList02 = new Item("02","pen",1000); 10 ArrayList itemList = new ArrayList(); 11 itemList.add(iList01); 12 itemList.add(iList02); 13 14 15 while(true){ 16 System.out.println("1.一覧表示"); 17 18 19 String inputSelectMenuNo = inputuser.readLine(); 20 21 if(inputSelectMenuNo.equals("1")){ 22 ShowItems showitems = new ShowItems(itemList); 23 //showitems.ShowItem(); 24 } 25 } 26 } 27}
Java
1import java.util.*; 2public class ShowItems { 3 private List<Item> itemList; 4 5 public ShowItems(ArrayList<Item> itemList ) { 6 this.itemList = itemList; 7 } 8 9public void ShowItem { 10 ProductsDisplay selectProductDisplay = new ProductsDisplay(itemList); 11 String showDisplay = selectProductDisplay.productsDisplay(); 12 System.out.println(showDisplay); 13 } 14}
Java
1import java.util.*; 2 3public class ProductsDisplay{ 4 5 private List<Item> iList; 6 7 public ProductsDisplay(ArrayList<Item> paramItemList){ 8 this.iList = paramItemList; 9 } 10 11 public String productsDisplay(){ 12 13 // String inputUserNo = inputNo; 14 String iListData = ""; 15 // if(inputUserNo.equals("1")){ 16 for(Item i : this.iList){ 17 iListData = (i.getItemCode() + "," + i.getItemName()+ "," + i.getPrice()); 18 } 19 // } 20 return iListData; 21 } 22 23}
上記実行したら
Main.java:61: error: constructor ShowItems in class ShowItems cannot be applied to given types;
ShowItems showitems = new ShowItems(itemList);
^
required: no arguments
found: ArrayList
reason: actual and formal argument lists differ in length
./ShowItems.java:4: error: cannot find symbol
ProductsDisplay selectProductDisplay = new ProductsDisplay(itemList);
^
symbol: variable itemList
location: class ShowItems
上記エラーがでましたが、解決方法がわからなく教えて頂きたいです
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/04/24 05:38
2021/04/24 05:39