How to Remove Elements from a LinkedHashMap in Java? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes 1 Likes Like Report A LinkedHashMap is a part of the Collection Framework from java.util package Java and is similar to a HashMap, except that a LinkedHashMap preserves the insertion order among the keys/entries. In this article, we will look at how to remove the elements from a LinkedHashMap in Java. Program to Remove Elements from a LinkedHashMap in JavaThe remove() method is the default method, which is usually used to remove an element from any data structure from the Collection Framework. We can use the remove() method to remove a single specified key from the LinkedHashMap. Syntax: <map-object>.remove(Object key) Below is the implementation to Remove Elements from a LinkedHashMap in Java: Java // Java Program to Remove // Elements from a LinkedHashMap import java.io.*; import java.util.*; class GFG { public static void main(String[] args) { // create a LinkedHashMap LinkedHashMap<String, Integer> map = new LinkedHashMap<String, Integer>(); // add elements(key-value pairs) to our map map.put("Java", 4999); map.put("Python", 2999); map.put("Go", 3999); map.put("Rust", 1999); System.out.println("Before, LinkedHashMap is: " + map); // remove the entry whose key is 'Python' Integer ret = map.remove("Python"); // print the returned value after removing entry for // 'Python' System.out.println( "The value returned by the removal 'Python' key is : " + ret); System.out.println("After, LinkedHashMap is: " + map); } } OutputBefore, LinkedHashMap is: {Java=4999, Python=2999, Go=3999, Rust=1999} The value returned by the removal 'Python' key is : 2999 After, LinkedHashMap is: {Java=4999, Go=3999, Rust=1999} Note : To remove all the elements from the LinkedHashMap, you can directly use the clear() method.You should not use LinkedInHashMap.remove() when iterating over elements using Iterator as it will throw ConcurrentModificationException.To know another method to remove elements from LinkedHashMap in Java refer to Remove() using Iterator Object. Create Quiz Comment G girish_thatte Follow 1 Improve G girish_thatte Follow 1 Improve Article Tags : Java Java Programs Java-Collections java-LinkedList Java Examples +1 More Explore Java BasicsIntroduction to Java3 min readJava Programming Basics9 min readJava Methods6 min readAccess Modifiers in Java4 min readArrays in Java7 min readJava Strings7 min readRegular Expressions in Java3 min readOOP & InterfacesClasses and Objects in Java5 min readAccess Modifiers in Java4 min readJava Constructors4 min readJava OOP(Object Oriented Programming) Concepts10 min readJava Packages2 min readJava Interface7 min readCollectionsCollections in Java12 min readCollections Class in Java13 min readCollection Interface in Java4 min readIterator in Java4 min readJava Comparator Interface5 min readException HandlingJava Exception Handling6 min readJava Try Catch Block4 min readJava final, finally and finalize4 min readChained Exceptions in Java3 min readNull Pointer Exception in Java5 min readException Handling with Method Overriding in Java4 min readJava AdvancedJava Multithreading Tutorial3 min readSynchronization in Java7 min readFile Handling in Java4 min readJava Method References9 min readJava 8 Stream Tutorial7 min readJava Networking6 min readJDBC Tutorial5 min readJava Memory Management3 min readGarbage Collection in Java6 min readMemory Leaks in Java3 min readPractice JavaJava Interview Questions and Answers15+ min readJava Programs - Java Programming Examples7 min readJava Exercises - Basic to Advanced Java Practice Programs with Solutions5 min readJava Quiz1 min readJava Project Ideas For Beginners and Advanced15+ min read Like