Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Removing Elements in java map

// Java program to demonstrate
// the working of Map interface

import java.util.*;
class Main {

	public static void main(String args[])
	{

		// Initialization of a Map
		// using Generics
		Map<Integer, String> hashmap1= new HashMap<Integer, String>();
		
		// Inserting the Elements
		hashmap1.put(1, "Apple");
		hashmap1.put(2, "Banana");
		hashmap1.put(3, "Mango");

		// Initial Map
		System.out.println("Initial Map :"+hashmap1+"
");

		hashmap1.remove(new Integer(2));

		// Final Map
		System.out.println("Updated Map :"+hashmap1);
	}
}
Comment

java remove map key

/*Suppose a map*/
Map<T> map = new HashMap<>();
/*Insert 2 keys, and remove one*/
map.put('First', 'John');
map.put('Second', 'Tommy');
// Returns a value, you don't have to save it if you want
String removedValue = map.remove('First');
Comment

PREVIOUS NEXT
Code Example
Java :: convert void * to int 
Java :: java read integer from text file into array scanner 
Java :: java string literals 
Java :: how junit test getter and setter 
Java :: java delete object 
Java :: read wss endpoint java 
Java :: how to create a gui in java 
Java :: java add element to existing array 
Java :: how to check if user is logged in firebase android and then load another activity 
Java :: java types of list 
Java :: fixed length array powershell 
Java :: Program to remove duplicates in an ArrayList 
Java :: How to check if a string is in alphabetical order in java 
Java :: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/firebase/iid/FirebaseInstanceId; 
Java :: comment générer un nombre aléatoire en java 
Java :: java.util.HashMap has generic type parameters, please use GenericTypeIndicator instead 
Java :: print in java 
Java :: what is jvm jdk and jre 
Java :: android studio setBackground 
Java :: smart ways to print a matrix in java 
Java :: java hashmap time complexity 
Java :: java ceil 
Java :: abstract code in java 
Java :: java print method 
Java :: get all enum values java 
Java :: queue.isempty java 
Java :: java set classpath 
Java :: call function after specific time java android 
Java :: A* shortest path algorithm 
Java :: Create JDBC connection using properties file 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =