---
type: archive
area: archive
status: archived
date: 2026-05-03
created: 2026-05-03
updated: 1980-01-01
tags:
  - archive
---
### Advanced Generics:
- Compiled generic code replace \<T>\ with Object Class
- Example:

![[img-20240819-155347-f8147826.png]]

- Java arrays are covariant which can result in runtime executions
- Generics of collection api are invariant code is validated at compile time.
- SO if we create a specific list with a predefined type we can not instantiate this list with another type that he is not the same of the predefined type.
### Wildcard Generics
- Creating a List without generics is the same like creating a list with \<Object>\ Type.
- Collection of unkown type \<?>\ turns any collection to read only collection. It allows us to create a covariant collection without any problem because it is read only
![[img-20240819-162432-dfcc4378.png]]

### Lower Bound Wildward
 - Contra-variant list is a list that accept a Type and all of his super classes 
 - It's writable you can add instance of Object, Product, Food to such a list.
 - List \<? super Food>\
 
![[Untitled design.png]]

- **Raw type** refers to using a generic class or interface without specifying a type parameter.