It seems that this snippet is throwing around random keywords without any understanding - I would suggest a Java tutorial. First of all, generics are one of the main uses for boxing. boolean
or any other primitives (you can recognise these by the fact that their identifiers are in lower-case and most IDEs will highlight them) cannot be used as a generic type, and their capitalised equivalent must be used (a simple wrapper class). Here, use HashMap<Person, Boolean>
.
I'm not sure what is meant by marked = new marked...
- clearly, marked
is not a type and cannot be used in this context. new x(params)
initialises an object of type x
, passing its constructor params
. new x<generics>(params)
is the same but the generic type(s) of x
are generics
.
Finally, new int
is not at all valid - see my explanation above. Primitives are not objects, which means initialising them is meaningless and therefore invalid. Also, what do you expect this expression to yield? Something of type int
, but you are not specifying which int
. The correct syntax is a literal: count = x;
where x
is some integer within the range of int
.
As a side note, your method has an unclear name and variables may be initialised in the same line you declare them to simplify code.