java中main方法引用带参数的方法只需通过创建对象来调用方法,并传入对应的参数值即可。
具体示例代码如下:
public class Demo1 {
private static String[] goodsName;
private static double[] goodsPrice;
private static int[] custNo;
private static int[] custScore;
private static String[] custBirth;
public static void main(String[] args) {
Demo3 demo = new Demo3();
demo.setData(goodsName, goodsPrice, custNo, custBirth, custScore);
}
}
主方法调用:
public class Demo3 {
private static String[] goodsName;
private static double[] goodsPrice;
private static int[] custNo;
private static int[] custScore;
private static String[] custBirth;
public static void setData(String[] goodsName1,double[] goodsPrice1,int[] custNo1,String[] custBirth1,int[] custScore1){
goodsName=goodsName1;
goodsPrice=goodsPrice1;
custNo=custNo1;
custScore=custScore1;
custBirth=custBirth1;
}
}