Skip to content
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
    • Spring Boot Tutorial
Home Posts tagged "Java map"

Tag: Java map

Java HashMap merge() With Examples

UshaK December 2, 2021 December 2, 2021Collections Java, Java collections, Java map 0

The Java HashMap merge() method is used to insert a new (key,value) pair into the HashMap or to modify value for an already existing key. Syntax of merge() method merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction) The parameters are- key– Key with which the resulting…

Continue reading

Java HashMap computeIfAbsent() With Examples

UshaK December 1, 2021 December 1, 2021Collections Java, Java collections, Java map 0

The Java HashMap computeIfAbsent() method is used to compute a new value for the specified key, if the specified key doesn’t already exist or key exists but mapped to null, in the HashMap. Syntax of computeIfAbsent() method computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction) The parameters are- key– Key…

Continue reading

Java HashMap computeIfPresent() With Examples

UshaK December 1, 2021 December 1, 2021Collections Java, Java collections, Java map 0

The Java HashMap computeIfPresent() method is used to compute a new value for the specified key if key already exists (and non-null) in the HashMap. Syntax of computeIfPresent() method computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction) The parameters are- key– Key with which the computed value has…

Continue reading

Java HashMap compute() With Examples

UshaK November 26, 2021 December 2, 2021Collections Java, Java collections, Java map 0

The Java HashMap compute() method is used to compute a new value for the specified key. Syntax of compute() method compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction) The parameters are- key– Key with which the computed value has to be mapped. remappingFunction– It is an expression of…

Continue reading

Map#putIfAbsent() in Java With Examples

UshaK November 24, 2021 November 26, 2021Collections, Java Java collections, Java map 0

In this tutorial you will see how to use putIfAbsent() method in Java HashMap. The putIfAbsent() method inserts the specified value if the passed key is not already present in the HashMap or the key is null. Using this method gives you an option to check if key is already…

Continue reading

HashMap Internal Implementation in Java

UshaK July 28, 2021 July 28, 2021Collections Java, Java collections, Java map 0

HashMap internal implementation in Java or how does HashMap work internally in Java is a very important interview question. Some of the important points that you should know are- Where does HashMap store its elements internally? What is the term “bucket” in HashMap? What is hashing concept and how does…

Continue reading

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

How to Remove Duplicate Elements From Java ArrayList

UshaK December 23, 2020 December 24, 2020Collections Java, Java collections, Java map 0

This post shows different ways to remove duplicate elements from ArrayList in Java. ArrayList in Java is designed to store repeated elements where as HashSet only store unique elements, using that feature of HashSet in Java you can remove duplicates from ArrayList. Only problem is HashSet is an unordered collection…

Continue reading

12
Privacy Policy | Disclaimer
Powered by Nirvana & WordPress.