A Bit about Stream Stream is a new feature added in java 8 and represents a sequence of elements. A stream originates from a collection which holds these elements. This collection may be an array, a list, a set, a map etc. It should be remembered that a stream itself does not hold any elements.Read More →

Iterating in reverse order means fetching last element of the map first, second last element at second position and so on. Simple logic is to start a loop from last position of the map till its beginning and fetch element at that position but unfortunatelyjava.util.Map interface or any of its implementations does not have a method to retrieve elements based on index hence you cannot fetch an element based on its position. So how can we reverse iterate a map. Read on !!!Read More →

Sorting values means arranging them in a particular order. The order may be ascending or descending. When the term sorting refers to a Map, it may be sorted on the basis of its keys or values. It depends completely on the requirement. Java 8 provides a convenient method to sort a map. Using this method will cut down the lines of code used by traditional methods of using java.util.TreeMapor java.util.Comparator to some extent.Read More →

Microsoft excel is the most widely used program to maintain data. Hence it becomes vital that the data from an excel sheet be read directly to a java program so that it may be used further to dump into a database or written to an XML file. Java itself does not provide any features to perform excel related operations but there are external libraries written in java which support this. Two of the common libraries are Apache POI and jexcel (or jxl). Both of them provide convenient methods to handle excel files. This post will be using jexcel (or jxl) api for its demonstration.Read More →

Microsoft excel is the most widely used program to maintain data. Hence it becomes vital that the data from a java program be directly written to an excel file in different rows and columns. Java itself does not provide any features to perform excel related operations but there are external libraries written in java which support this. Two of the common libraries are Apache POI and jexcel (or jxl). Both of them provide convenient methods to handle excel files. This post will be using jexcel (or jxl) api for its demonstration.Read More →

Most applications require calculating current date for different reasons. It may be for logging events, for saving the creation, updation or deletion time of entities, recording the login details of a user and so on. Java provides different methods to calculate current date and time. Following article explains different methods to obtain current date and/or time in java.Read More →

What is Stack ? A linear data structure which stores newly added items at its top and retrieves newly added items from its top. Consider a pile of books where each new book added to the pile is placed at its top and at the time of removal, the book at the top is removed. A stack works on LIFO (Last In First Out) principle and supports only two operations :Read More →