In this post, we will discuss the Java generics naming conventions with examples.
Read complete Java naming conventions at https://www.javaguides.net/2018/08/java-standard-naming-conventions.html.
The most commonly used type parameter names are:
Read complete Java naming conventions at https://www.javaguides.net/2018/08/java-standard-naming-conventions.html.
Generic type parameter names should be uppercase single letters. The letter 'T' for a type is typically recommended. In JDK classes, E is used for collection elements, S is used for service loaders, and K and V are used for map keys and values.
public interface Map <K,V> {}
public interface List<E> extends Collection<E> {}
Iterator<E> iterator() {}
- E - Element (used extensively by the Java Collections Framework)
- K - Key
- N - Number
- T - Type
- V - Value
- S,U,V etc. - 2nd, 3rd, 4th types
Reference
Free Spring Boot Tutorial - 5 Hours Full Course
Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course