This website uses cookies to ensure you get the best experience on our website. Learn more

Generics in Java


Generics in Java

In a nutshell, generics enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods.
Much like the more familiar formal parameters used in method declarations, type parameters provide a way for you to re-use the same code with different inputs.
The difference is that the inputs to formal parameters are values, while the inputs to type parameters are types.

Code that uses generics has many benefits over non-generic code:
- Stronger type checks at compile time.
A Java compiler applies strong type checking to generic code and issues errors if the code violates type safety.
Fixing compile-time errors is easier than fixing runtime errors, which can be difficult to find.
- Elimination of casts.
- Enabling programmers to implement generic algorithms.
By using generics, programmers can implement generic algorithms that work on collections of different types, can be customized, and are type safe and easier to read.

In this video we will see :
- What is Generics
- What is Type-safe Language
- How to achieve type safety
- An example or program of Generics implementation in Java

Check out our website:

Follow Telusko on Twitter:

Follow on Facebook:
Telusko :
Navin Reddy :

Follow Navin Reddy on Instagram:

Subscribe to our other channel:
Navin Reddy :
Telusko Hindi :

Generics in Java | Java Generics Tutorial | Java Certification Training | Edureka

** Java Certification Training: **
This Edureka video on Generics in Java will talk about what is generics, its methods, functions, etc. It will also showcase a demo to help you understand Java Generics concepts in a detailed way. Below topics are covered in this video:
1:16 - What is Generics in Java?
1:50 - Why Generics?
3:12 - Types of Generics in Java
10:24 - Generic Functions
13:07 - Advantages of Generics in Java

Check out our Java Tutorial blog series:

Check out our complete Youtube playlist here:


Do subscribe to our channel and hit the bell icon to never miss an update from us in the future:


#edureka #Java #JavaGenerics #LearnJava #JavaOnlineTraining #edurekajava

How it Works?

1. This is a 7 Week Instructor-led Online Course, 45 hours of assignment and 20 hours of project work.
2. We have a 24x7 One-on-One LIVE Technical Support to help you with any problems you might face or any clarifications you may require during the course.
3. At the end of the training, you will be working on a real-time project for which we will provide you a Grade and a Verifiable Certificate!
- - - - - - - - - - - - - - - - -

About the Course

Edureka's Advanced Java J2EE and SOA training and certification course is designed for students and professionals who want to be a Java Developer. This is a 42-hour course which will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XML Handling etc. We will also learn various Java frameworks like Hibernate and Spring. During our Java/ Certification training, our instructors will help you:

1. Develop the code with various Java data types, conditions, and loops.
2. Implement arrays, functions and string handling techniques.
3. Understand object-oriented programming through Java using Classes, Objects and various Java concepts like Abstract, Final etc.
4. Implement multi-threading and exception handling.
5. Use parse XML files using DOM and SAX in Java.
6. Write a code in JDBC to communicate with the Database.
7. Develop web applications and JSP pages.
8. Interact with the database using hibernate framework.
9. Write code with spring framework components like Dependency Injection and Auto Wiring.
10. Implement SOA using web services.

- - - - - - - - - - - - - - - - - - -

Who should go for this course?

This course is designed for professionals aspiring to become Java Developers. Programmers, Web Developers, Web Designers, Programming Hobbyists, Database Administrators, Youngsters who want to kick-start their career are the key beneficiaries of this course.
- - - - - - - - - - - - - - - -

Why learn Java?

Java is a general-purpose, class-based, object-oriented computer programming language that was designed by James Gosling at Sun Microsystems in 1995.

Key Highlights of Java:

Platform Independent: This allows programmers to develop applications that can run on any operating system.

Usability of Java: Java is most widely used programming language. It is present everywhere. It really doesn't matter which domain you are working in, you will surely come across Java sooner or later!

Open Source: The good news is that Java is available for free! All the development tools and the environment (JRE & JDK) that is used to develop Java applications are absolutely free of cost.

Android: Irrespective of the fact that you are tech savvy or not, most of us are badly bitten by the Android bug! Android is in great demand today and fortunately you need Java for Android development. Hence, the importance of Java has increased even more.

Hadoop: Hadoop is one of the most trending frameworks for processing Big Data. It has been designed and developed in Java.


Got a question on the topic?
Please share it in the comment section below and our experts will answer it for you.

Please write back to us at or call us at IND: 9606058406 / US: 18338555775 (toll-free) for more information

Java 3 Introduction to Generic Programming

Dr. Rob Edwards from San Diego State University introduced generic programming in Java

Java Generics

Take my Full Java Certification Course (17 hrs long) for just $15 bucks using the link:

- Course Last Updated Jan 2019!
- Latest updates include Lambdas and Streams with Java 9 Features.

Welcome to The Complete Java Certification Course.  This course is designed to help you master the most in-demand and critical components for becoming a Core Java developer. Especially if you're going for a job interview or have a Java Project that needs your best performance. This course assumes no prior java experience so  prior Java so it will take you from zero to hero!

The topics covered include Object Orientation which I think is not stressed enough in other Java courses so I've got special focus on that throughout the lectures. You'll get plenty of practice writing classes and interfaces as well as countless methods with loops and if else statements, exception handling and file processing as well as how to debug software using Eclipse. You'll also be mastering the collections framework and diving deep into java generics. You'll learn all there is to know about multi-threading and the JDBC API for working with a MySQL database. There are also practical projects scattered throughout the course so that you can practice the concepts as you learn them. For example one of the projects is related to a car dealership management system and another assignment involves processing files with stock market data. So as you can see I tried to keep the projects professional and industry relevant rather than cloning a game like flappy bird.

I want this course to be the ultimate go-to resource for anyone that's looking to become a core Java programmer so I intend on adding more content to this course based on new technologies and student feedback. The content is Java 9 ready which means I'll show you how to upgrade to the latest version of Java which is version 9 and I'll teach you how to configure Eclipse to work with both Java 8 as well as version 9.

I'm confident that you'll enjoy this course at-least as much if not more than my other popular Java courses, but as always you've got a 30 day money back guarantee no questions asked! Check out the preview lectures and join today!


Java Basics
Working with Java Data Types
Using Operators and Decision Constructs
Creating and Using Arrays
Using Loop Constructs
Working with Methods and Encapsulation
OOP Basics
Working with Inheritance
Java Class Design
Handling Exceptions
Working with Selected classes from the Java API
Advanced Class Design
Generics and Collections
Lambda Built-In Functional Interfaces
Java Stream API
Exceptions and Assertions
Use Java SE 8 Date/Time API
Java I/O Fundamentals
Java File I/O (NIO.2)
Building Database Applications with JDBC

Java Generics Tutorial

Java Generics Tutorial.
Complete Course 200+ Videos, 24 Hours - JAVA PROGRAMMING for Complete Beginners in 250 Steps -

Follow Ranga on LinkedIn -

Our Top 10 Courses
30+ Courses. 500,000+ Learners. Amazing Reviews.

► 1. Master DEVOPS with Docker, Kubernetes and Azure DevOps -
► 3. Master MICROSERVICES with Spring Boot and Spring Cloud -
► 4. Become AWS CERTIFIED Solution Architect -
► 5. Learn SPRING in 100 Steps -
► 6. JAVA PROGRAMMING for Complete Beginners in 250 Steps -
► 7. Go FULL STACK DEVELOPER with Spring Boot and Angular -
► 8. Master Java Unit Testing with Spring Boot & Mockito -

FREE Courses For You

► 01. Learn Full Stack, AWS, Cloud, and Microservices -
► 02. Learn Spring and Spring Boot in 5 DAYS -
► 03. AWS Certified Solutions Architect Associate -
► 04. Getting Started with DevOps and Cloud -
► 05. Learn Docker in 10 Steps -
► 06. Learn Kubernetes in 10 Steps -
► 07. Learn AWS in 10 Steps -

Other Recommendations


Step By Step Details

Generics in java # 1 - Introduction to Generics in java | Java tutorials by

Java Generics helps to introduce more type safe code and develop more generic algorithms which are more reusable and generate less runtime errors. I have used a very simple example to explain why we need Generics in java

Introduction to Generics (Type Safety)

DURGASOFT is INDIA's No.1 Software Training Center offers
online training on various technologies like JAVA, .NET ,
courses from Hyderabad & Bangalore -India with Real Time Experts.
Mail us your requirements to
so that our Supporting Team will arrange Demo Sessions.
Ph:Call +91-8885252627,+91-7207212428,+91-7207212427,+91-8096969696.

This is the classroom video at DURGASOFT. If possible you can write notes also as it is class room direct video.
Content : Generic (Type Safety)

Java - Generic Method & Class

Java - Generic Method & Class
Watch more videos at
Lecture By: Ms. Monica, Tutorials Point India Private Limited

Java Generics Tutorial

My Gear:

#keeponcoding #tech #programming

Intermediate Java Tutorial - 17 - Generic Methods

Facebook -
GitHub -
Google+ -
LinkedIn -
reddit -
Support -
thenewboston -
Twitter -

Collection and Generics in Java

Complete Playlist :
Spring Boot Tutorials :

Github :-

Recommend Books :

1. Head First Java :
2. Java Complete Reference :

Join the live batch :

Collection Framework in Java
ArrayList , List, Set, Hashset, TreeSet
Map and Hashmap.

Generics to store a specific type of objects. Generics work on collections of different types can be customized, and are type-safe and easier to read.

collection: It is word represent the Collection Object and Map object.

Collection: The super Interface of all Collection such as Array.

Collections: is a utility class, which has specific methods to work with collections.

Why Learn JavaScript? | Should You learn JS in 2017? :

Why Use Linux? :

Editing Monitors :

Editing Laptop :
ASUS ROG Strix - (new version)

Camera :
lens :


Check out our website:

Follow Telusko on Twitter:

Follow on Facebook:
Navin Reddy:

Follow Navin Reddy on Instagram:

Subscribe to our other channel:
Navin Reddy:
Telusko Hindi :

Subscribe to the channel and learn Programming in an easy way.

Java Tutorial for Beginners :

Scala Tutorials for Java Developers :

C Tutorial Playlist:

Android Tutorial for Beginners Playlist:

XML Tutorial:

Design Patterns in Java :

Socket Programming in Java :

Spring MVC Tutorial :

Spring Framework with Maven:

Sql Tutorial for Beginners :

String Handling in Java :

Array in Java :

Java Servlet :

Exception Handling in Java :

Java Generics Tutorial

- This is a broad tutorial on what Generics are in Java and how to use them.
Also, I'm launching an intensive, 6 month long, part-time Coding Bootcamp where I'm guaranteeing that every graduate will get a job. If that sounds interesting, you can learn more via

Java Generics I - The Basics

First part of a short series on Java Generics - this one explains the basics

Table of contents:

0:50 motivation
2:50 how to create a generic class
4:04 concept vs runtime behavior
5:50 how to create a generic methods
8:51 generics vs `static`
11:40 type inference
13:31 live-coding demonstrating all of the above
14:46 type variable names


Nicolai on Twitch:
Nicolai on Twitter:

Java Generics Tutorial - 053

At some point you've likely heard about Java generics. Generics were introduced into the Java language in Java 5. In the next few videos, we're going to take a deep dive into what generics are, how to use them, and ultimately how to create our own Java generics.

A generic is a class that acts like a template for creating classes. In this case, we define how the list works without stating what classes the list holds. We'll have add and remove methods, but we won't say what class we're adding and removing until we define the instance. Once we instantiate our class, we'll tell it the type our list works with. No other type is allowed. Using a generic class gives us type safety.

#java #programming #tutorial #generics

Like the video? Don't forget to subscribe! ➜

Keep up to date with the newsletter! ➜

Transcript ➜ ‎

Concepts: Java generics, Java

Social Links: Don't hesitate to contact me if you have any further questions.

About Me:

Related Videos:

Media credits: All images are owned by DJ Spiess or used under CC0 unless listed below

Airport Lounge - Disco Ultralounge by Kevin MacLeod is licensed under a Creative Commons Attribution license (

Hands-on Java - Creating a Generic Class - Day 22

In todays hands-on-Java episode we are creating a generic class! Enjoy!

Enjoy my content? Subscribe for free! -

My Dev/Entrepreneurship show -

Want to learn code? Try Pluralsight for free -

Need help getting a job? -

My recommended Web Hosting -

Amazing BenQ Lamp -

~~~~~~~~~~~~~~~ Additional Links ~~~~~~~~~~~~~~~

Instagram -
Twitter -
Facebook -
More content -
Patreon -
Donate -

What are Java Generics?

Have you ever seen Java code with angle brackets in a type like perhaps
ArrayLists of HashMaps? Those are called Generics, because they are generic classes that can use any kind of class in them.

In this lecture, designed for second year programming students at Westmont College, Prof. Patterson introduces the motivations and syntax for Java Generics. He shows how to both *use* a class that leverages Generics as well as how to *create* classes that leverage Generics themselves. When you are done you will have a better understanding of how to maximize your code reuse and improve your code architecture.

Get that code crackin'!

Summary of Java Generics (Advanced)

In this video I give a fast (13 minutes) summary of Java Generics.
The video is best suited to those with a basic understanding of Generics, who want to refine there skills, I cover a lot of ground without going too far into the weeds.

Apologies for the editing - the transitions are a bit rough.

Generics with Wildcards in Java

Java Generics Wildcards

Question mark (?) is the wildcard in generics and represents an unknown type. The wildcard can be used as the type of a parameter, field, or local variable and sometimes as a return type. We can't use wildcards while invoking a generic method or instantiating a generic class.

The Good, Bad, and Ugly of Java Generics

The Generics feature of the Java language was intended to bring overall type safety to Java. This session starts at the basics of Generics and looks at its capabilities. It presents some of the under-the-hood details of Generics implementation and then delves into some of the changes to Java libraries for accommodating Generics. Finally, it takes a look at some restrictions and pitfalls we need to be familiar with when it comes to relying on Generics.

Copyright © 2013 Oracle and/or its affiliates. Oracle® is a registered trademark of Oracle and/or its affiliates. All rights reserved. Oracle disclaims any warranties or representations as to the accuracy or completeness of this recording, demonstration, and/or written materials (the Materials). The Materials are provided as is without any warranty of any kind, either express or implied, including without limitation warranties of merchantability, fitness for a particular purpose, and non-infringement.

Intermediate Java Tutorial - 18 - Implementing a Generic Method

Facebook -
GitHub -
Google+ -
LinkedIn -
reddit -
Support -
thenewboston -
Twitter -



Check Also