Monday, July 23, 2012

How object in Java is initialized

1. A class is loaded when it is used for the first time, it is loaded from the class file (Ex. Student.class). If this class has a base class, the base class will be loaded before this class.  2. Next, the static initialization in the base class is performed which initialize the static fields of the base class, and then the static initialization of this (derived) class kicks in, which makes...

Monday, July 9, 2012

Sunday, July 8, 2012

Java Generics Wildcards explained

Given a generic class, like List<T>, or any generic class: When using this generic class, for example: List<Student> students = StudentFactory.getStudents(); or public class StudentList implements List<Student> {...} or List<? extends Student> students = StudentFactory.getStudents(); or List<?...