Java Collection API is one of the most useful APIs used in any Java application. In my day to day Java coding routine, I have to deal with these APIs quite often.However sometime while working with Collection API, lot of developers end up writing unnecessary and mostly inefficient code. For example, to convert an Java ...
Recently I had a requirement where using Spring MVC we had to take inputs multiple rows of data from user. The form had many rows which user can edit and submit. Spring MVC provides very simple yet elegant way of collecting data from multiple rows from HTML form and store them in List of Beans in Java.Lets look at the requirement first. We have a ...
While working with Doubles and Long numbers in Java you will see that most of the value are displayed in Exponential form.For example : In following we are multiplying 2.35 with 10000 and the result is printed.//Division example Double a = 2.85d / 10000; System.out.println("1) " + a.doubleValue());//Multiplication example a = 2.85d * 100000000; System.out.println("2) " + a.doubleValue());Result:1) 2.85E-4 2) 2.85E8Thus you can see the result is ...
Recently while working in one of the requirement, I had to convert String values to Enum. I didn't realize there is a simplest way of doing this. Here is the solution.Whenever an ENUM is complied in Java, two static methods are added by compiler called valueOf() and values(). We can use valueOf() method to convert any String value to ENUM. For example lets say we ...
As a Java developer, lot of times I have to play around with file system. Sometimes I have to copy files/directories from one location to another; sometimes have to process certain files depending on certain pattern. In one of my test program, I wanted to calculate available disk space using Java. Lot of code snippets are ...
Here is a small but very useful tip that every Java programmer should be aware of. Have you ever tried sorting arrays in Java? Well, java.util.Arrays class has built in method to make your job easy. You can use following method to sort any array in Java.import java.util.Arrays; ... ... Arrays.sort (int ) Arrays.sort (float ) Arrays.sort (long ) ...Let us check an example were we will sort an array of ...
iText is a wonderful library if you want to generate PDFs in Java. It comes with a huge set of API to create/manage a PDF file. We already saw in our previous tutorial
how to generate a pdf file in itext and also
how to merge ...
Quote 1: Avoid creating unnecessary objects and always prefer to do Lazy Initialization Object creation in Java is one of the most expensive operation in terms of memory utilization and performance impact. It is thus advisable to create or initialize an object only when it is required in the code.public class Countries {private List countries; public ...
The European Commission on Thursday approved Oracle Corp.'s acquisition of Sun Microsystems after regulators were assuaged over the fate of an open-source database, James Gosling have paid respect to Sun Microsystem on his
blog. Please go to his blog and pay your respect to Sun.
Welcome to Part-3 of 7-part series of tutorials where we will go through different practical aspects of Struts2 Framework. In the last part we Created a
Basic Struts2 Application from Scratch. I strongly recommend you to go through the previous articles in case you are new to Struts2.In this article we will learn how to ...