submited by krishnas on Thu Mar 27th, 2008
java
ArrayList and HashMap are a few of the most frequently used data structures in Java development. So I would like to talk about the importance of instantiating these classes with initial capacity. Let me explain how the ArrayList works internally, so that you get a good insight. HashMap works almost the same way an ArrayList works, so I haven’t covered the details of that separately. But all the tips given below are applicable for HashMap as well....
more »
submited by krishnas on Thu Mar 27th, 2008
java
During my Java training, I read about volatile keyword, but didn’t get clear understanding. Recently when I wrote a singleton class using double checked locking, PMD code reviewer gave a warning not to use volatile. Later I started exploring on double checked locking issue, here is my observation....
more »
submited by krishnas on Thu Mar 27th, 2008
java
This is one of the frequently asked questions in the interview. Most of the interviewer expect the below answer.
“Thread.stop() method is deprecated, so a boolean variable has to be introduced in thread class and run method should check the boolean variable whether to continue execution or come out of run() method”....
more »
submited by krishnas on Thu Mar 27th, 2008
java
Singleton is one of the frequently used and easily understandable design pattern. Most of the tutorials and books give example of making the constructor as private and exposing a static method which will provide single instance. The common example they use is Runtime class of JRE....
more »
submited by krishnas on Thu Mar 27th, 2008
hibernate java java5
This is the ant task I’m using to generate POJO and mapping files from a DB Schema (mysql)....
more »
submited by krishnas on Thu Mar 27th, 2008
java
Lets take this time in consideration a real life project. Most of the time Ant is used to compile and build java projects. This means generating, compiling and building jar files. For this we are going to define severals tasks. Lets consider the we create a buid.xml file in the directory where sources are located. The sources are put in the subdirectory called src. We also need to include a jar in the classpath while compiling. We are going to create a separate property file to define the location of this file:...
more »
submited by krishnas on Thu Mar 27th, 2008
java java6 google-guice
Google Guice is a lightweight dependency injection framework for Java 5 (or later), which is explained here very well....
more »
submited by krishnas on Thu Mar 27th, 2008
java java7
Well, the JDK7 Project is underway, and despite the fact that I am being moved into the .NET world for some new projects, I wanted to leave some parting thoughts with the Java community. By no means do I consider myself the ultimate authority on the following topics, however, these are a few things that I propose would make Java a better, more friendly, more flexible language....
more »
submited by krishnas on Wed Mar 26th, 2008
java
A few years ago I worked on a very big Enterprise IBM Websphere project. We had some brilliant engineers in the project both in the development and architecture groups. I remember having had several discussions with some of the brightest people on the team regarding PHP and dynamic languages and generally they were looked upon as toy languages without a bright future. Lack of strict typing, scripting performance, and other reasons were given for why Java would persevere as the language of choice....
more »
submited by krishnas on Wed Mar 26th, 2008
java java5
Do you shy away from using the Java collection framework? Do you find the unwieldy notation puts you off using the classes in this framework? If so, you may be writing unnecessary Java code. Stephen Morris shows you how easy and efficient the collection framework is to use....
more »