I have a java program which runs properly.
But when I try to clean and build it in Netbeans it is choking on this line:
protected HashMap<String, ArrayList<HashMap<String,String>>> config1
config1 = new <String,ArrayList<HashMap<String,String>>> HashMap(); // build breaks here.
the error is:
cannot find symbol
symbol : constructor
<java.lang.String,java.util.ArrayList<java.util.HashMap<java.lang.String,java.lang.String>>
>HashMap()
You are placing your type parameters in wrong place. It comes in between HashMap
and the ()
: -
config1 = new HashMap<String,ArrayList<HashMap<String,String>>>();
Also, its a good idea to have more generalized types rather than specific types in the declaration, and even in generic type parameters
. So you should use Map
instead of HashMap
in declaration, and List
instead of ArrayList
in your type parameter
: -
And actually, you don't need to break your declaration and initialization in two lines. Just have them in one single line. It looks more cleaner. So, you can change your two lines to: -
protected Map<String, List<Map<String,String>>> config1 =
new HashMap<String, List<Map<String,String>>>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With