Почему в моих результатах отображаются местоположения, а не названия ингредиентов? [дубликат]JAVA

Программисты JAVA общаются здесь
Гость
Почему в моих результатах отображаются местоположения, а не названия ингредиентов? [дубликат]

Сообщение Гость »

Код: Выделить всё

class Burger extends Food { private int numberofPatty; public Burger(){ } public Burger(String name, String[] ingredients, double price,float calories, int numberofPatty){     super(name,ingredients,price,calories);     this.numberofPatty= numberofPatty; } public void setNP(int numberofPatty){     this.numberofPatty= numberofPatty; } public int getNP(){     return numberofPatty; } public void showdetails(){     System.out.println("Name="+getName());     System.out.println("In="+ getIn());     System.out.println("Price="+getPrice());     System.out.println("Calories="+getCalories());     System.out.println("NP="+numberofPatty); } 
}

'

Код: Выделить всё

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();          } } 
thats the burger class, showdetails is the output i want

i tried array concept. what should i do to get the output with ingredients name?


Источник: https://stackoverflow.com/questions/781 ... ngredients

Вернуться в «JAVA»