Created
March 19, 2015 07:13
-
-
Save shcherbakoff/1c5e3ad9747d4ea23977 to your computer and use it in GitHub Desktop.
/* Вывести на экран список ключей
Есть коллекция HashMap<String, String>, туда занесли 10 различных строк. Вывести на экран список ключей, каждый элемент с новой строки.
*/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.javarush.test.level08.lesson03.task04; | |
import java.util.HashMap; | |
import java.util.Map; | |
/* Вывести на экран список ключей | |
Есть коллекция HashMap<String, String>, туда занесли 10 различных строк. Вывести на экран список ключей, каждый элемент с новой строки. | |
*/ | |
public class Solution | |
{ | |
public static void main(String[] args) throws Exception | |
{ | |
HashMap<String, String> map = new HashMap<String, String>(); | |
map.put("Sim", "Sim"); | |
map.put("Tom", "Tom"); | |
map.put("Arbus", "Arbus"); | |
map.put("Baby", "Baby"); | |
map.put("Cat", "Cat"); | |
map.put("Dog", "Dog"); | |
map.put("Eat", "Eat"); | |
map.put("Food", "Food"); | |
map.put("Gevey", "Gevey"); | |
map.put("Hugs", "Hugs"); | |
printKeys(map); | |
} | |
public static void printKeys(Map<String, String> map) | |
{ | |
for(Map.Entry<String, String> pair : map.entrySet()) | |
{ | |
String key = pair.getKey(); | |
System.out.println(key); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment