简体   繁体   English

Java:值类型为ArrayList时的地图列表

[英]Java : List of Maps when type of values is ArrayList

I'm working on a java project and i want to create a list of Maps that the type of keys is Character and the values are ArrayLists of Characters. 我正在一个Java项目上,我想创建一个键类型为Character且值为ArrayLists of Characters的Maps列表。 I have written something like this : 我写了这样的东西:

List<Map<Character, ArrayList<Character>>>

but the eclipse says : Syntax error on token ">>>", VariableDeclarator expected after this token 但是日食说: Syntax error on token ">>>", VariableDeclarator expected after this token

How can i do it ? 我该怎么做 ? any idea ? 任何想法 ?

The compiler is expecting a variable name to comply with Java syntax: 编译器期望变量名符合Java语法:

List<Map<Character, List<Character>>> myList = 
                              new ArrayList<Map<Character, List<Character>>>();

List<Map<Character, ArrayList<Character>>> list ; should be given 应给予

see the screen shot below 见下面的屏幕截图

在此处输入图片说明

您可以将变量声明为接口(例如List ),但是要创建实例,必须选择一个实现(例如ArrayList ):

List<Map<Character, ArrayList<Character>>> myList = new ArrayList<Map<Character, ArrayList<Character>>>();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM