“Hashmap Java” Kode Jawaban

Java hashmap baru

Map<String, String> myMap = new HashMap<String, String>() {{
        put("a", "b");
        put("c", "d");
    }};
Fair Fly

Hashmap di Java

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

public class HashhMap {
    public static void main(String[] args){
        Map<String, String> map = new HashMap<>();
        map.put("myName","Kumaran");
        map.put("myProgram", "Java");
        map.put("Designation", "Java Developer");

        Set<String> key = map.keySet();


        for(String keys: key){
            System.out.println(keys+ " : "  +map.get(keys));
        }
    }
}
Kumaran KM

Hashmap Java

package org.o7planning.tutorial.javacollection.helloworld;

import java.util.HashMap;

public class HelloHashMap {

	public static void main(String[] args) {

		// Créer un objet HashMap qui stocke les paires des ID d'employés et des salaires.
		// Clé de chaîne: ID d'employé
		// Valeur flottante: Salaire.
		HashMap<String, Float> salaryMap = new HashMap<String, Float>();
	 

		salaryMap.put("E01", 1000f);
		salaryMap.put("E02", 12000f);
		salaryMap.put("E03", 12300f);
		salaryMap.put("E04", 1000f);
		salaryMap.put("E05", 300.5f);
		
		// Obtenir les salaires des employés 'E02'
		Float salary= salaryMap.get("E01");
		System.out.println("Salary of employee E01 = "+ salary);
		
		// Mettre à jour le salaire pour les employés 'E05'
		salaryMap.put("E05", 400f);
		
		System.out.println("Salary of employee E05 = "+ salaryMap.get("E05"));
		 
	}

}
Tame Tortoise

Hashmap Java

    private static final Map<Integer, String> map = Map.of(
        1, "one",
        2, "two"
    );
Vivacious Vulture

Java Hashmap

import java.util.HashMap; // import the HashMap class

HashMap<String, String> capitalCities = new HashMap<String, String>();
naly moslih

Jawaban yang mirip dengan “Hashmap Java”

Pertanyaan yang mirip dengan “Hashmap Java”

Lebih banyak jawaban terkait untuk “Hashmap Java” di Java

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya