Last active
April 8, 2023 09:18
-
-
Save pavly-gerges/2fe95035aab7f116e868fb01a2f1305e to your computer and use it in GitHub Desktop.
Generics in java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Wrapper { | |
private Object object; | |
public Wrapper(Object object) { | |
this.object = object; | |
} | |
public void setObject(Object object) { | |
this.object = object; | |
} | |
public Object getObject() { | |
return object; | |
} | |
} |
Resources
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
API Design Tips
When designing your API, you should be aware of the following rules:
For class type generics and generic method type parameters:
For wildcard generics:
Last, but not least, in order to decide the best type of boundaries to use, think of the final type-erasure you want to have on your API:
Here is a nice tip from the Java tutorials: