Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package com.mycompany.ex23;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.LinkedHashSet;
- import java.util.Map;
- import java.util.Set;
- public class Main4 {
- public static void main(String[] args) {
- // Тип Ключа, Тип Значения
- Map<String, String> m = new HashMap<>();
- // put - поместить значение по ключу
- m.put("KEY", "VALUE");
- m.put("KEY", "VALUE2");
- m.put("KEY2","VALUE3");
- // get - извлечь значение по ключу
- System.out.println("m.value=" + m.get("KEY"));
- //
- System.out.println("m.size=" + m.size());
- // Set
- // List, Set, Map
- Set<String> set = new HashSet<>();
- set.add("ONE");
- set.add("ONE");
- set.add("TWO");
- System.out.println("set.size=" + set.size());
- Set<String> setOrdered = new LinkedHashSet<>();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement