Skip to content
Snippets Groups Projects
Commit ebb05e52 authored by Mahboobe Shakeri's avatar Mahboobe Shakeri
Browse files

adding hashMap example

parent fba26066
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@
import java.util.Scanner;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.HashMap;
public class Main {
public static void main(String[] args) {
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
......@@ -10,6 +11,28 @@ public class Main {
System.out.println("changes in the merge");
System.out.println("Hello Mahboobe changing the code online!");
HashMap<String, Integer> grades = new HashMap<>();
grades.put("Mahboobe", 87);
grades.put("Chris", 86);
System.out.println(grades);
grades.put("Mahboobe", 90);
System.out.println(grades);
for( String name : grades.keySet()){
System.out.println(name + " " + grades.get(name));
}
System.out.println("check if we have Anne grade: " + grades.containsKey("Anne"));
System.out.println("check if we have Mahboobe grade: " + grades.containsKey("Mahboobe"));
System.out.println("check if we have 90 grade: " + grades.containsValue(90));
System.out.println("check if we have Anee grade: " + grades.get("anne"));
HashMap<String, String> grades2 = new HashMap<>();
grades2.put("Mahboobe", "A-");
grades2.put("Chris", "B+");
System.out.println(grades2);
// ArrayList, Hashset, Hashmap
// hashSet example
// HashSet<String> names = new HashSet<>();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment