我不能像下面的代码那样初始化一个List
List<String> supplierNames = new List<String>();
supplierNames.add("sup1");
supplierNames.add("sup2");
supplierNames.add("sup3");
System.out.println(supplierNames.get(1));
我面临以下错误。
无法实例化 "List
"类型。
我怎样才能将List<String>
实例化?
你将需要使用ArrayList<String>
之类的。
List<String>
是一个接口。
使用这个。
import java.util.ArrayList;
...
List<String> supplierNames = new ArrayList<String>();