Wildcard:
In generics ‘?’ is known as wildcard and it represents an unknown type.
Types of wildcard:
- 1. Unbounded wildcard.
- 2. Bounded wildcard.
1. Unbounded wildcard.is used for list of unknown types using ‘?’(Type is not bounded).
2. Bounded wildcard: is used for unknown bounded types using ‘?’ with extends or super keyword.
2. Bounded wildcard: is used for unknown bounded types using ‘?’ with extends or super keyword.
- a. Upper bounded wildcard. is used to restrict the unknown type to be a specific type or a subtype of that type using ‘?’ with extends keyword.
- b. Lower bounded wildcard. is used to restrict the unknown type to be a specific type or a super type of that type using ‘?’ with super keyword.
No comments:
Post a Comment