vinoth kumar
vinoth kumar

Reputation: 679

What does this declaration mean?

For this declaration

final Map<?, ?> qBuilders;

what does it mean?

Upvotes: 1

Views: 196

Answers (4)

user467871
user467871

Reputation:

? - It means any java type (String, Integer...)

Upvotes: 0

Andreas Dolk
Andreas Dolk

Reputation: 114767

It declares the class attribute qBuilders. This variable must be initialized in a constructor and you can't assign another value to that attribute afterwards (but you can change the map keys and values - you just can't exchange the entire map).

Map is a generic interface, <?,?> are the type parameters for this attributes. ? is a wildcard and just tells, that this map accepts any java type for keys and values.

Upvotes: 4

Tyler Treat
Tyler Treat

Reputation: 14988

While your question is fairly vague, the final keyword, in the context of a variable, means the variable can only be assigned once. If the variable is a field of a class, it has to be assigned in the constructor of said class.

Upvotes: 0

Dr G
Dr G

Reputation: 4017

It's a blank final. You can assign to the variable once but you cannot reassign the variable after that, however it does not render the qBuilders map immutable. You can still call its method and use the map as usual. See the explanation on Wikipedia for instance.

Upvotes: 0

Related Questions