Home » Java Basics » generics


Generic Method Example in Java

In this example, we will be studying about generic methods and how to use the same in our programmes. Generic method, as the name suggests, is a method that does not specify the Type of its parameters, per se. Rather, it defines a criteria (or a place holder) by which, the method introduces its own type parameters. We will try ...

Read More »

Java Generics Examples

In this post, we feature a comprehensive article on Java Generics. 1. The Motivation for Java Generics The simplest way to think about Java generics is thinking about a sort of a syntactic sugar that might spare you some casting operation: 1 2 List<Apple> box = ...; Apple apple = box.get(0); The previous code is self-speaking: box is a reference ...

Read More »