最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【已解决】Java代码中new List时出错:Cannot instantiate the type List<NameValuePair>

Java crifan 10698浏览

【背景】

折腾:

【教程】模拟登陆百度之Java代码版

期间,需要去New一个List:

List<NameValuePair> headerDict = new List<NameValuePair>();

结果出错:

Cannot instantiate the type List NameValuePair

即:

Cannot instantiate the type List<NameValuePair>

【解决过程】

1.和之前的:

【基本解决】java中没法new:Cannot instantiate the type HttpParams

类似,所以就是去找到,list的某个实现类型,即可。

2.参考:

Cannot instantiate the type List<Product>

去试试:

List<NameValuePair> headerDict = new ArrayList<NameValuePair>();

然后就可以了:

 

【总结】

Java中的代码,还真的不适应。。。

没有C#用的爽。

转载请注明:在路上 » 【已解决】Java代码中new List时出错:Cannot instantiate the type List<NameValuePair>

78 queries in 0.253 seconds, using 19.21MB memory