在特定行上声明数组

时间:2019-04-02 08:52:54

标签: java

我正在为Java使用基于收据的项目,用户必须输入产品ID,输入产品ID后,将显示“数量”和“所选数量”,但问题是数量显示怪异文字。

Scanner id = new Scanner (System.in);
    String products [] = {"Donut", "Ice Cream", "Kitkat", "Marshmallow", "Nutella"};
    int prices [] = {25, 15, 40, 60, 150};
    int number [] = {0, 1, 2 ,3 , 4};
    System.out.println("                Menu                "); 
    System.out.println("Item ID         Item Name:                  Price (in Php)");
    System.out.println(number [0]+" "+products [0]+"                                "+prices[0]);   
    System.out.println(number [1]+" "+products [1]+"                             "+prices[1]);
    System.out.println(number [2]+" "+products [2]+"                                "+prices[2]);
    System.out.println(number [3]+" "+products [3]+"                             "+prices[3]);
    System.out.println(number [4]+" "+products [4]+"                                "+prices[4]);
    System.out.println();
    System.out.print("Select ID Number: ");
  int ID = id.nextInt();
    System.out.println("Input quantity: ");
  int QUANTITY = id.nextInt();
  System.out.println("Product ID:"+ ID);
  System.out.println("Product Quantity: "+QUANTITY);
  System.out.println("Product Price: "+prices);

预期输出: 产品编号:2 产品数量:3 产品价格:15

但是实际输出是: 产品编号:2 产品数量:3 产品价格:[I @ 55f96302

0 个答案:

没有答案