Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Map did not accept "boolean" [duplicate]

Maybe is a newbie question, but I don't understand why when I try to do something like Map<String, boolean> my IDE screams saying "Syntax error on token "boolean", Dimensions expected after this token", but with Boolean it works perfect. Can anyone explain me why is it like that? Thanks in advance!!

like image 553
raspayu Avatar asked Sep 10 '25 15:09

raspayu


1 Answers

Simply put: Java generics don't work with primitive type arguments, only classes. So in the same way, you can't use List<int>, only List<Integer>.

See the relevant Java Generics FAQ entry for more information.

like image 70
Jon Skeet Avatar answered Sep 12 '25 04:09

Jon Skeet