Friday, 22 August 2014

5 main differences between HashTable and HashMap

HashMap and Hashtable both implement java.util.Map interface but there are some differences that Java developers must understand to write more efficient code. 1)One of the major differences between HashMap and Hashtable is that HashMap is non-synchronized whereas Hashtable...
Read More »

Thursday, 21 August 2014

Java Collections - Map

Map is an interface which is not derived from Collections interface as described in our previous post Java Collections. Map follows its own hierarchy . It stores a key -value pair in which key should be unique and value can be anything related. We use put method to store key-value pair in Map. Can...
Read More »

Sorting of ArrayList

Sorting of an array list is one of main tasks of a developer. There are mainly two ways to sort an array list. 1. Using natural order 2. Using Comparator interface . For both methods we will use sort () method which is defined in Collections utility class. See : How to reverse a string in java How...
Read More »

Wednesday, 20 August 2014

Java Collections -Set

Set a Collection used to store Unordered but unique elements. If you try to store a duplicat element in a set it will throw an error. Example of set Set setA = new HashSet(); String element = "element 1"; setA.add(element); System.out.println( set.contains(element) ); Implemenation of set Since...
Read More »

Tuesday, 19 August 2014

How to iterate through list in java

List is a collection in java used to store Ordered objects which can be duplicate. List can be used to store either primitive data type or instances of a defined class. how to store object /instance...
Read More »

How Objects are stored in heap and Stack in java

HEAP AND STACK IN JAVA 1. Stack is memory in computer which is used to store temporary information. For eg. variables are stored on stack. 2.Information after the method is done with its...
Read More »

Saturday, 16 August 2014

How to add List to another List

How to reverse a string in java package test; import java.util.ArrayList; import java.util.List; import java.util.ListIterator; public class MainS { /* we have two lists as l and b and will add and reterieve list l to b */ public static void main(String[] args) { List l= new ArrayList(); ...
Read More »

How to add instance of a class to list and then retrieve it

Suppose we have a class Car with 2 properties Car model and car name. We want to add instances of this class to a list so that later we can retrieve it. See : How to sort an Array List without using Comparator or sort method Overriding/method Overriding In java Difference between Application...
Read More »

List in java Collection

List : It is an interface inheritd from Collections for ordered collection of objects. It can contain duplicate elements. How is ArrayList different from Array? ArrayList Array Is not definite in size. Can expand according to requirement. Is definite in size. Stores objects Store primitive...
Read More »

Java Collections- Everything you want to know

Collection is an interface - is a framework which allows for using and manipulating collections. Set- A collection that cannot contain duplicate elements. 2. Elements are in unordered manner. List-...
Read More »

Thursday, 14 August 2014

Hibernate Interview Questions

1. Call Back Interfaces These interfaces are helpful to receive notifications about changing state of an object such as saved , loaded , deleted. There is no need to implement callback interfaces in hibernate. See :How to sort an Array List without using Comparator or sort method 2. which...
Read More »