import java.util.HashMap; public class Main { public static void main(String[] args) { // HashMap implements the Map interface (need import) // HashMap is similar to ArrayList, but with key-value pairs // stores objects, need to use Wrapper Class // ex: (name,email),(username,userID),(country,capital) HashMap countries = new HashMap(); //add a key and value countries.put("USA","Washington DC"); countries.put("India","New Delhi"); countries.put("Russia","Moscow"); countries.put("China","Beijing"); //System.out.println(countries); //countries.remove("USA"); //System.out.println(countries.get("Russia")); //countries.clear(); //System.out.println(countries.size()); //countries.replace("USA", "Detroit"); //System.out.print(countries.containsKey("England")); //System.out.print(countries.containsValue("Beijing")); for(String i : countries.keySet()) { System.out.print(i+"\t"+"= "); System.out.println(countries.get(i)); } } }
Hi Bro, hope you're doing well Your videos and explanations about Java and many other programming languages you have on the channel are excellent, understandable and very helpful. You make a complicated subject much simpler. I was wondering if you could add to the playlist, videos that explain the interfaces: List, Set, Map. And an explanation of their implementers: HashSet, HashMap, TreeMap, TreeSet, SortedMap, SortedSet, etc.
@@BroCodez theres a big demand for knowledge in the world because most of them cant afford it and want to find free ways to learn .thank you so much for ur videos
When i first heard about Sets and Maps i always thought i'd never use those but they are, in fact, actually easier than actual arrays, i'm kinda mind blown.
I have been studying Java for 6 months, and my university, as much as the lectures try to help, is absolutely useless, especially for someone like me who suffers from learning disabilities, but your videos are amazing... I wish I found it sooner. They teach me things and help me understand in 1-3 days compared to a month and only half understanding it through my university. Thank you so much! I am been acing my tests with your tutorials xd.
3:39 the diamond operator at the end of the instantiation does not need to take in the String values. Java infers the type from the first portion! Hey, I actually know something about Java. Feels good.
At 11:11, why does it not list the hashmap in the same order in which it was created? As always, great video. I started at video number 3 and this is number 76. Plan to do them all. Not just watching, but I'm doing them myself. Loving it. Your consistency in how you explain is remarkable.
every time you say we should like comment and subscribe to defeat the algorithm im like how do i subscribe again TnT bc ive watched like 30 of your videos i can only subscribe once lmao
There are too many things need to understand, such as collections , list, especially Linkedlist, it is abstract. And tree map. I don’t understand what is tree map. In Chinese they say a word 红黑树 , which means red and black tree style to store hash code.
Bro Code because if you use different color to mark a tree map, it will be more easy to find a certain hash code I think. For example base level is black, and second level is red, and third level is black. But I am also don’t know, why it is called black and red tree.