Home » Java Basics » generics

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

The Motivation for 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: List<Apple> box = ...; Apple apple = box.get(0); The previous code is self-speaking: box is a reference to a List of objects of type Apple. The get method returns an Apple instance ...

Read More »

Want to take your Java skills to the next level?

Grab our programming books for FREE!

Here are some of the eBooks you will get:

  • Spring Interview QnA
  • Multithreading & Concurrency QnA
  • JPA Minibook
  • JVM Troubleshooting Guide
  • Advanced Java
  • Java Interview QnA
  • Java Design Patterns