在Java中,当您希望函数返回多个值时,必须
- 将这些值嵌入到您返回的对象中
- 或更改传递给函数的对象
在您的情况下,您显然需要定义一个
Show可以包含
name,
quantity和的类
price:
public class Show { private String name; private int price; // add other fields, constructor and accessors}然后将您的功能更改为
public Show test(){ ... return new Show(GoodNameShow,QuantityShow ,GoodUnitPriceShow) ;


