Sobes.tech
Junior — Middle

Millises Java versioonides tutvustati genrikke?

sobes.tech AI

Vastus AI-lt

Generics were introduced in Java starting from version Java 5 (J2SE 5.0). This allowed creating classes, interfaces, and methods with type parameters, which increased type safety and reduced the need for type casting.

Example of using generics:

List<String> list = new ArrayList<>();
list.add("Example");
String s = list.get(0); // Safe, without explicit casting