• 25 June

    How to iterate over Map or HashMap in java

    In this post, we will see how  can we iterate a map in java. There are four ways of iterating over a map, HashMap or TreeMap. Java HashMap tutorial: HashMap in java How HashMap works in java hash and indexfor method in HashMap hashcode and equals method in java How to sort HashMap by keys […]

  • 24 June

    How to iterate a list in java

    In this post, we will see how  can we iterate a list in java. There are four ways of iterating over a list. For loop For each loop(Java 5) While loop Iterator Below example will help you to understand, how to iterate list in java. I am taking custom object list to understand better 1. […]

  • 12 September

    TreeSet in java

    In this post, we will see TreeSet in java. Java TreeSet have following properties: It can contain only unique element. It stores objects in ascending order by default, It implements NavigableSet interface which extends SortedSet. When you put objects in TreeSet, it must implement Comparable interface. Lets understand it more with the help of example. […]

  • 01 May

    LinkedHashSet in java

    In this post, we will see about LinkedHashSet in java. LinkedHashSet is same as HashSet except that it maintains insertion order. Some points about LinkedHashSet LinkedHashSet implements Set interface and extends HashSet class. LinkedHashSet maintains insertion order, so when you will be able to access elements in the order they were inserted like ArrayList. Example: LinkedHashSetMain.java [crayon-62d6523d0f328679775250/] When you run […]

  • 19 July

    How HashSet works in java

    In this post, we will see about Hashset in java Java HashSet: [crayon-62d6523d0f7e5381670239/] This is one of the frequently asked question in core java interview so in this post, we will see how HashSet works in java.We have already seen How hashMap works in java and also difference between HashMap and HashSet. Lets first see […]

  • 24 February

    hashcode() and equals() method in java

    In this post ,we will try to understand hashcode() and equals() method in java. Java HashMap: HashMap in java How HashMap works in java hash and indexfor method in HashMap hashcode and equals method in java How to sort HashMap by keys and values Difference between HashMap and HashSet Difference between HashMap and Hashtable How […]

  • 29 April

    TreeMap in java with examples

    TreeMap class implements Map similar to HashMap. Some important points about TreeMap: TreeMap implements Map interface and extends HashMap class. TreeMap is implemented using Red black tree based NavigableMap. TreeMap is ordered collection and store its elements in natural ordering of keys. Key which you would like to put in TreeMap must implement Comaparable interface or you can […]

  • 28 April

    LinkedHashMap in java

    LinkedHashMap is a Hashtable and linked list-based implementation of Map interface, with predictable insertion order. It maintains double linked list of all its entries, that’s how it differs from HashMap. Java LinkedHashMap Some points about LinkedHashMap LinkedHashMap implements Map interface and extends HashMap class. LinkedHashMap maintains insertion order, so when you will be able to […]

  • 04 May

    How HashMap works in java

    Most common interview questions are <code>How HashMap works in java</code>, “How get and put method of HashMap work internally”. Here I am trying to explain internal functionality with an easy example. [crayon-62d6523d10de1364480416-i/]  is one of the most used Collections in java.Rather than going through theory, we will start with example first, so that you will […]