Sunday 25 April 2021

What is Map in Java? How to create and run loop in Map and Set?

 




  • Map is an interface
  • Part of Collection
  • Key and value pair
  • Usage: Search, edit and delete elements respective to key
  • Map doesn't allow duplicate keys.
  • Hashmap will allow null keys and values
  • Methods: getKey(), getValue(), entrylist


CODE to run loop with Map and Set?

public static void listcheck() {

 

   Map<String,String> hmap= new HashMap<String,String>();

   hmap.put("urigetuser","https://reqres.in/api/users?page=2");

   hmap.put("first_name","janet");

   

   Set<String> hset = new HashSet<String>();

   Set<Entry<String, String>> esets = hmap.entrySet();

   for (Map.Entry<String, String> ent : esets) {

   System.out.print(ent.getKey() + ent.getValue());

   }

 }


*************************************************

SeleniumWebdriver Automation Testing Interview Questions:

API Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Rest-API

 
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes

 
Docker Interview Question Set
https://automationreinvented.blogspot.com/2020/02/top-18-docker-commands-for-aytomation.html

 
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux

 
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign


Java Related Interview Question Set

https://automationreinvented.blogspot.com/search/label/Java


GIT Interview Question Set:
https://automationreinvented.blogspot.com/search/label/GIT


Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions




No comments:

Post a Comment

All Time Popular Posts

Most Featured Post

Introduction to Web Testing with Playwright

  Introduction to Web Testing with Playwright 📌  Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 📌  YouTube channel:  https://lnkd.in/gGUG...