最新消息:20210917 已从crifan.com换到crifan.org

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

Java crifan 7527浏览 0评论

【背景】

折腾:

【教程】模拟登陆百度之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>

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
92 queries in 0.185 seconds, using 23.34MB memory