Powered by Blogger.

What are Generics in Java

>> Saturday, March 28, 2015

In common term Generic means a common type of things or relating to a class or group of things not specific.

In Java Generics are introduced in 2004 within Java 5.0 features along with Enum, autoboxing and varargs , to provide compile time type-safety.Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods or, with a single class declaration, a set of related types, respectively.
What is type-safety?
It is just a check by compiler that correct Type(datatype) is used in correct place and there should not be any ClassCastException.

Related Posts Plugin for WordPress, Blogger...
© javabynataraj.blogspot.com from 2009 - 2014. All rights reserved.