KnpCode
Java, Spring, BigData, Web development tutorials with examples
 
Skip to content
  • Ubuntu
  • Big Data
    • Hadoop Tutorials
  • Java
    • Core Java Tutorials – Beginner
    • Core Java Tutorials – Advanced
    • Java Programs
  • spring
    • Spring Framework
Home Posts tagged "Java collections"

Tag: Java collections

How to Sort Java HashMap

UshaK January 4, 2021 January 5, 2021Collections Java, Java collections, Java map 0

HashMap in Java calculates hash based on the key of the inserted (key, value) pair and store its elements according to that. So essentially HashMap is an unordered collection but you may come across a scenario when you want to sort HashMap in Java. Sorting on HashMap can be done…

Continue reading

How to Iterate a Java HashMap

UshaK January 3, 2021 January 5, 2021Collections Java, Java collections, Java map 0

In this post we’ll see different ways to iterate a Map or HashMap in Java. One thing you should know is you can’t directly loop a Map in Java (except when you use forEach statement). There are methods that return a “collection view” of the Map using that view you…

Continue reading

Java HashMap With Examples

UshaK January 3, 2021 January 5, 2021Collections Java, Java collections, Java map 0

HashMap in Java is the HashTable implementation of the Map interface and it is part of the Java Collections framework. HashMap class in Java extends AbstractMap class and implements Map, Cloneable and Serializable inerfaces. HashMap stores its elements as (key, value) pairs and to get a value you will need…

Continue reading

LinkedList Internal Implementation in Java

UshaK January 2, 2021 January 5, 2021Collections Java, Java collections, java list 0

In the post ArrayList Internal Implementation in Java we have already seen the internal implementation details of one of the implementation of the List interface – ArrayList. In this post we’ll see LinkedList internal implementation in Java which is another implementation of the List interface Questions that may come up…

Continue reading

Convert Array to ArrayList in Java

UshaK January 2, 2021 January 5, 2021Collections Java, Java collections, java list 0

In the post How to Convert ArrayList to Array in Java we have already seen different ways of doing that conversion. This post is about the other way round how to convert array to ArrayList in Java. Options for converting array to ArrayList in Java Using Arrays.asList() method. See example.…

Continue reading

How to Sort ArrayList of Objects in Java

UshaK January 1, 2021 January 4, 2021Collections Java, Java collections, java list 0

In this post we’ll see how to sort ArrayList of objects in Java. In the post How to Sort ArrayList in Java we have already seen how you can sort ArrayList of String, Date or any Wrapper class (Integer, Float etc.). All those classes already implement Comparable interface so you…

Continue reading

How to Synchronize Java ArrayList

UshaK January 1, 2021 January 4, 2021Collections Java, Java collections, java list 0

This post shows how to synchronize ArrayList in Java and what other thread safe alternatives are available to use. ArrayList in Java is not thread safe as it is not synchronized by default. If you are using ArrayList in a multi-threaded environment where it is accessed by multiple threads concurrently…

Continue reading

How to Synchronize Java HashSet

UshaK December 31, 2020 January 4, 2021Collections Java, Java collections, Java set 2

This post shows how to synchronize HashSet in Java and the HashSet’s thread safe alternative which can be used instead of a HashSet. HashSet is not thread safe HashSet in Java is not thread safe as it is not synchronized by default. If you are using HashSet in a multi-threaded…

Continue reading

HashSet Internal Implementation in Java

UshaK December 30, 2020 January 4, 2021Collections Java, Java collections, Java set 0

HashSet internal implementation in Java or how does HashSet work internally in Java is a very important interview question. Some of the important points that you should know are- What is the backing data structure for HashSet or where does HashSet stores its element? How does add() method work in…

Continue reading

How to Iterate a Java HashSet

UshaK December 29, 2020 January 4, 2021Collections Java, Java collections, Java set 0

In this post we’ll see different ways to iterate a Set or HashSet in Java. Your options to iterate a HashSet are as follows- You can use For-Each loop (Advanced or enhanced for loop), available from Java 5. You can iterate a HashSet using Iterator. Using iterator() method you can…

Continue reading

1234
Privacy Policy | Disclaimer
Powered by Nirvana & WordPress.
We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.OkPrivacy Policy