我的构造函数方法如下所示:
Object
如果我想在不同的类中调用该方法,如何传递类型列表的参数?
答案 0 :(得分:1)
您应该像这样创建对象Profile
的istance:
List<PointGrade> list = new ArrayList<PointGrade>();
Profile profile =new Profile(list);
你可以使用这种方式:
profile.someMethod();
答案 1 :(得分:0)
// ...
// file has to be writeable!
if (!is_writeable($file)) {
throw new RuntimeException(
sprintf('File %s is not writeable!', $file)
);
}
file_put_contents($file,
sprintf('<?php return %s;', var_export($config, true)));
答案 2 :(得分:0)
Profile profile = new Profile(new List<PointGrade>());
答案 3 :(得分:0)
创建List的实例:
List<PointGrade> list = new ArrayList<PointGrade>();
用一些数据填充它(如果你不想传递空列表):
PointGrade pg = new PointGrade();
//fill PointGrade fields you need
list.add(pg);
然后将其传递给构造函数:
Profile profile = new Profile(list);