From 64b7dec1b0c761e322c304a1176ecdc8b38579ab Mon Sep 17 00:00:00 2001 From: akeshri Date: Tue, 8 Sep 2020 21:14:28 +0530 Subject: [PATCH] changes --- map-first-key-tutorial/README.md | 4 -- .../com/baeldung/article/HashMapExample.java | 36 ------------------ .../article/LinkedHashMapExample.java | 37 ------------------- 3 files changed, 77 deletions(-) delete mode 100644 map-first-key-tutorial/README.md delete mode 100644 map-first-key-tutorial/src/com/baeldung/article/HashMapExample.java delete mode 100644 map-first-key-tutorial/src/com/baeldung/article/LinkedHashMapExample.java diff --git a/map-first-key-tutorial/README.md b/map-first-key-tutorial/README.md deleted file mode 100644 index 13fb71643b..0000000000 --- a/map-first-key-tutorial/README.md +++ /dev/null @@ -1,4 +0,0 @@ -# HashMap - Getting First Key And Value -A example on how to get first key and value from HashMap. - -- JDK 1.8 and above \ No newline at end of file diff --git a/map-first-key-tutorial/src/com/baeldung/article/HashMapExample.java b/map-first-key-tutorial/src/com/baeldung/article/HashMapExample.java deleted file mode 100644 index 3292d995ab..0000000000 --- a/map-first-key-tutorial/src/com/baeldung/article/HashMapExample.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.baeldung.article; - -import java.util.AbstractMap; -import java.util.HashMap; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; - -/** - * @author AshwiniKeshri - * - */ -public class HashMapExample { - public static void main(String[] args) { - - Map hashmap = new HashMap<>(); - hashmap.put(5, "A"); - hashmap.put(1, "B"); - hashmap.put(2, "C"); - // hashmap.put(0, "D"); - - System.out.println(hashmap); - - Set> entrySet = hashmap.entrySet(); - - Iterator> iterator = entrySet.iterator(); - - if (iterator.hasNext()) - System.out.println("Using Iteraor: " + iterator.next()); - - System.out.println("Using Stream: " + entrySet.stream() - .findFirst() - .orElse(new AbstractMap.SimpleEntry(-1, "DEFAULT"))); - - } -} diff --git a/map-first-key-tutorial/src/com/baeldung/article/LinkedHashMapExample.java b/map-first-key-tutorial/src/com/baeldung/article/LinkedHashMapExample.java deleted file mode 100644 index 249b9a0585..0000000000 --- a/map-first-key-tutorial/src/com/baeldung/article/LinkedHashMapExample.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.baeldung.article; - -import java.util.AbstractMap; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Set; - -/** - * @author AshwiniKeshri - * - */ -public class LinkedHashMapExample { - - public static void main(String[] args) { - - LinkedHashMap linkedHashMap = new LinkedHashMap<>(); - linkedHashMap.put(5, "A"); - linkedHashMap.put(1, "B"); - linkedHashMap.put(2, "C"); - // linkedHashMap.put(0, "D"); - - System.out.println(linkedHashMap); - - Set> entrySet = linkedHashMap.entrySet(); - - Iterator> iterator = entrySet.iterator(); - - if (iterator.hasNext()) - System.out.println("Using Iterator: " + iterator.next()); - - System.out.println("Using Stream: " + entrySet.stream() - .findFirst() - .orElse(new AbstractMap.SimpleEntry(0, "DEFAULT"))); - } - -}