Code&Data Insights
[Java programming ] Generic 본문
[ Generic ]
: 클래스 내부에서 지정하는 것이 아닌 외부에서 사용자에 의해 지정되는 것.
: 컬렉션 프레임 워크에서 많이 사용되어짐
- Generics add that type of safety feature.
- Generics are used in HashSet / ArrayList / HashMap
- The syntax of generic
* To create an instance of generic class
* BaseType <Type> obj = new BaseType <Type>()
* We cannot use primitive data types like int, char
- Type Parameters in Java Generics
-> T : Type
-> E : Element
-> K : Key
-> N: Number
-> V : Value
- Advantages of Generics
: Programs that use generics has got many benefits over non-generic codes.
ð Code Reuse / Type Safety
'Computer Science > Java Programming' 카테고리의 다른 글
[ Java Programming ] Interface (0) | 2022.04.17 |
---|---|
[ Java Programming ] Thread (0) | 2022.04.17 |
[JAVA Programming ] java.lang.Object class methods, hashcode() (0) | 2022.04.11 |
[JAVA Programming ] Instance, static variables, ArrayList (0) | 2022.04.11 |
[JAVA Programming] Loop function & Recursion (반복함수, 재귀함수) (0) | 2022.01.23 |
Comments