Java Version History

Java Version History

Java Version History article describes about the history of the different java versions released.

From it's inception, java language is undergone several changes.

Java's first version (JDK 1.0) was released on the year 1996, January 23 and first version's codename was oak. This release consists with 8 packages and 212 classes

From version 1.4, Java language development is undergone according to the rules of Java Community Process (JCP), and they uses Java Specification Requests (JSR) to propose and specify improvements and changes to the Java Language.

JCP helped the development process of java language to become a community driven to a greater extend

Parsing XML String Using DOM

Parsing XML String Using Java DOM

Parsing XML String Using DOM Example describes about Parsing XML String Using DOM parser.

How To Parse / Read XML File In Java?

Consider the below example xml file, where you need to parse that xml and extract all the student names of that file,

Here we are using DocumentBuilderFactory, DocumentBuilder & Document  in order to create an instance of Dom object, so that we can easily parse that Dom object.

Package org.w3c.dom is a Java API for XML Processing, This package helps to manipulate the Document Object Model (DOM). The Dom element represents the entire XML or HTML document.

Sort ArrayList Of Object

Sort ArrayList Of Object

Sort ArrayList Of Object Example describes about How to sort an ArrayList of objects.

How to Sort An ArrayList Of Objects Using Comparator Interface

The best way to sort an ArrayList of Objects is using Collections.sort() method of Collections utility class.

But if you need to sort according to a particular field / column / property, then we can use Comparator interface and override compare method of Comparator interface.

Consider an ArrayList consists with lot of student objects, where student object have 2 properties like firstName & lastName. And you need to sort according to the firstName, then you can use comparator interface for sorting the ArrayList

int compare(T o1, T o2) Compares its two arguments for order.

Increasing Heap Size in Eclipse

Increasing Heap Size in Eclipse Example explains about how to set Heap Size in Eclipse and Avoiding OutOfMemoryError

There are 2 ways you can Increase Heap Size in  Eclipse

1) Change eclipse.ini (inside Eclipse folder)

-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
512m
-vmargs
-Xms40m
-Xmx512m

Java For Loop Example

Java For Loop Example

Java For Loop Example describes about how to use for loop in java.

The general template of for statement is following

for (initialization; termination; increment){ 
	statement(s) 
} 

When you use "for loop" you need to follow below rules

The initialization condition initializes the loop; it is executed only once, as the loop begins. if the termination condition tests to false, the loop exits. The increment condition is invoked after each iteration through the loop;

The following are the different ways we can use for loop in java