Welcome to my blog !


Find last Element/Object of ArrayList in java

November 22, 2011 ·  1 min read

get the Last Element of List  Most of the times we encountered the situation to read the first element of ArrayList using get(0) method. Some instances you want to read the last element of an array List, you can use the following code snippet. `ArrayList list=new ArrayList(); list.add("one"); list.add("two"); list.add("three"); list.add("four"); ` To Access the fourth object, we have to use list.get(list.size()-1). Here size() method returns the size of the list and size -1 return the last index of the list....

Pros and Cons of Design patterns

November 18, 2011 ·  1 min read

In Software development, reusable code to solve the frequent problems occurred in the designation of any system In OOPS programming, we have several design patterns the following are the Popular design patterns There are different categories types of design patterns in object-oriented programming 1. Creation patterns:- This type of patterns are used to describe the object creation in the best possible ways in different contexts. Singleton is the example 2.Structural design patterns:- 3....

Singleton Design pattern

November 18, 2011 ·  2 min read

Singleton design pattern It is one of the design patterns to maintain the single instance of an object in a system. whenever object created using the new Object() code, one new instance created, if we call these, multiple instances are created in heap memory. Over the time the calls to the new objects grow, the size of the object size grows in the heap memory and it will cause performance overhead....

Linux and Unix PS commands Examples

November 15, 2011 ·  4 min read

process status command Unix/Linux Examples PS abbreviated as process status command list information about the active process running in the Linux/Unix machine. this command list out all the active running process of a shell. We will see frequently used ps command examples in below sections. All these commands execute in the Linux/Unix command line ps command without arguments Ps command without arguments list out all the process of a current shell...

How to avoid ConcurrentModificationException for map or List

November 11, 2011 ·  1 min read

ConcurrentModificationException exception is occurred because of while one thread is iterating the collections and other thread trying to modify the object in collections. This will be happened for below map and list of collections. 1. Modifying state of any key or value in map implementations(example,HashMap,HashTable,LinkedHashMap) during iteration of Map objects 2.Adding/remove(Iterator.remove) the object in a collections class while iteration of collection of objects at the same time. you can use ConcurrentHashMap for avoiding this exception but there is no guarantee of all your objects are iterated....