Generics

What is it?  How do define it? How to use it? Why use it?What is Generics?• Generics provides abstraction over Types            > Classes, Interfaces and Methods can be Parameterized by Types (in the same way a Java type is parameterized by an instance of it)• Generics makes type safe code possible       … Read More Generics

J2SE 5.0 Language Features

Seven Major New Features• Generics• Autoboxing/Unboxing• Enhanced for loop (“foreach”)• Type-safe enumerations• Varargs• Static import• MetadataAutoboxing/Unboxing of Primitive Types• Problem: (pre-J2SE 5.0)        > Conversion between primitive types and wrapper types (and vice-versa)        > You need manually convert a primitive type to a wrapper type before adding it to a collectionint i =… Read More J2SE 5.0 Language Features

Collection Framework

What is a Collection? • A “collection” object — sometimes called a container      — is simply an object that groups multiple elements into a single unit• Collections are used to store, retrieve, manipulate, and communicate aggregate data      > Typically, they represent data items that form a natural group, such as a poker hand (a… Read More Collection Framework

Core Java – Polymorphism

What is Polymorphism?● Polymorphism– The ability of a reference variable to change behavior according to what object instance it is holding.– This allows multiple objects of different subclasses to be treated as objects of a single super class, while automatically selecting the proper methods to apply to a particular object based on the subclass it belongs to.Example: Polymorphism●… Read More Core Java – Polymorphism