为什么我的输出显示位置而不是成分名称?

问题描述 投票:0回答:1
public class Main {
    public static void main(String[] args) {
    
        String[] burgerIngredients = new String[2];

        burgerIngredients[0]= new String("alu");
        burgerIngredients[1]= new String("Potato");



        Burger burger1 = new Burger("Classic Burger", burgerIngredients, 5.99, 550, 1);
        

    


    burger1.showdetails();
    
    }
}

我尝试了数组概念。我应该怎么做才能获得带有成分名称的输出?

java arrays output
1个回答
0
投票
You can use get method to print all ingredient details. 

public String[] getIngredients() {
        return ingredients;
}


It would be helpful if you can show burger class like using showdetails() u wanted to print ingredient details?
© www.soinside.com 2019 - 2024. All rights reserved.