Тёмный
No video :(

How to create your own Generic HashMap in Java | Interview Question | Put, Get, Remove 

Krac X
Подписаться 700
Просмотров 15 тыс.
50% 1

This is one way on how to create a working HashMap implementation in Java. This is commonly an interview question.
In this tutorial, I show you how to code the put, get and remove operations.
pastebin.com/X...

Опубликовано:

 

5 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 42   
@lianhuang5
@lianhuang5 Месяц назад
非常好的,教學通俗易懂,希望大佬後續可以繼續出一個新的hashmap使用紅黑樹取代單向鏈表的寫法
@MediaFilter
@MediaFilter 2 года назад
Many thanks for sharing a basic implementation. This is exactly what I was looking for a few years ago - clear and well communicated!
@TurtleKicks
@TurtleKicks 2 года назад
went from showing minecraft tutorials to explaining hashmaps the best out there now that's what I call good character development
@MrKracx
@MrKracx 2 года назад
yeah man ive been all over the map xD
@liambmn
@liambmn 3 месяца назад
Thank you! Massively useful for my CS course. And Paint as a visualisation tool is great!
@vitorg.teixeira
@vitorg.teixeira 9 месяцев назад
Great video! I find much better to learn by creating your own implementation, and only then going to code challenges!
@ArpGupta-oy4zx
@ArpGupta-oy4zx 2 месяца назад
Amazing !!! respect
@junaidanjumansari6400
@junaidanjumansari6400 3 года назад
Good explanation, you win one more subscriber
@jcmejio
@jcmejio 3 года назад
Excellent video. Many Thanks! One question: shouldn’t we use equals() for comparison in this example? If we define the hashTable with then it may need to be adjusted.
@MrKracx
@MrKracx 3 года назад
Thanks Juan. It is probably better to use .equals(), yes. Thanks for pointing it out
@vedantgadhvi9315
@vedantgadhvi9315 5 месяцев назад
This is really an apt explanation! Thank you!
@frankqin1633
@frankqin1633 4 месяца назад
Clear logic, concise code! thx!
@snico5529
@snico5529 Год назад
in the while in the put fonction we can do this to no ? while (current != null) { if (current.key.equals(key)) { current.value = value; return; } if (current.next == null){ break; } current = current.next; } current.next = entry;
@andreansihombing6780
@andreansihombing6780 3 месяца назад
What is this code below purpose in remove method? Entry prev = e; e = e.next; while (e != null) { if (e.getKey() == key) { prev.next = e.next; e.next = null; return e; } prev = e; e = e.next; } I delete this code, and turn out fine without it. I can still remove data on the middle.
@programmingwithnish483
@programmingwithnish483 7 месяцев назад
yea, this is what i was looking for. thanks man
@nasersuliman8181
@nasersuliman8181 3 года назад
many thanks, perfect explanation
@hamzaali9803
@hamzaali9803 2 года назад
Really good video thank you. The concepts were explained very clearly. Appreciate your efforts.
@reshihashim4094
@reshihashim4094 2 года назад
Amazing work done.. Made it look cakewalk .... Thanks tons...
@yoo17
@yoo17 Год назад
Thank you!! Very informative!!
@pranjalikhule2000
@pranjalikhule2000 3 года назад
Amazing Explanation!!
@shubhamdeshkar1685
@shubhamdeshkar1685 2 года назад
How to get rid of the unchecked assignment warning on line 33?
@davannaleah
@davannaleah 11 месяцев назад
A couple of questions: How big is the array in the standard HashMap class provided in Java? I would think that 8 is rather small and you are just using 8 as a simple example. Can the standard array size be changed? Thanks for the video!
@MrKracx
@MrKracx 11 месяцев назад
docs.oracle.com/javase/8/docs/api/java/util/HashMap.html HashMap() Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75). you dont have to worry about changing the side, it happens automatically in the class
@mattg9601
@mattg9601 2 года назад
While Entry needs to have why does the Node in a linked list class not need it. It still access the Generic without the explicit signature.
@MrKracx
@MrKracx 2 года назад
Sorry I don't quite understand your question. Entry IS the "node".
@mattg9601
@mattg9601 2 года назад
@@MrKracx All good. Im asking like when you create a LinkedList Node private class I dont explicity put "private class Node {" but I can access the generic in the constructor. I was wondering why this is not the case for the Entry class in a HastMap.
@MrKracx
@MrKracx 2 года назад
@@mattg9601 hmm if you have a different setup than me and it works you can keep it. its hard to see what your doing without code, if you want you can create a pastebin and paste it there and send me a link . i will look at it
@shivaneeshinde3879
@shivaneeshinde3879 3 года назад
Superb
@lianhuang5
@lianhuang5 Месяц назад
希望有大佬可出一個中文字幕版本的,我們中國人聽這個真是有點吃力,只能直接看代碼了,後悔上學的時候沒有好好學習英文
@prasadm3614
@prasadm3614 3 года назад
Very good one !!
@matthewsarsam8920
@matthewsarsam8920 2 года назад
Great vid!
@divineATheaven
@divineATheaven 8 месяцев назад
Thanks Bro 🤘
@gam4524
@gam4524 Год назад
In my opinion we don’t need getters and setters in entry class
@antonrv6269
@antonrv6269 3 года назад
NIce explanation!!!
@ghanshyamkhatri3541
@ghanshyamkhatri3541 3 года назад
super Awesome!!
@yasaswinib9020
@yasaswinib9020 11 месяцев назад
Why is hashmap a array of Entry but not array of LinkedList?
@stepovyk01
@stepovyk01 9 месяцев назад
There is no sense to have access to previous node
@lianhuang5
@lianhuang5 Месяц назад
因為hashmap只需要做查找就行,對於查找來說只需要能夠從前往後或者從後往前,能夠支持一種方向遍歷就行,兩種都支持反而是一種冗餘了
@kikilin7918
@kikilin7918 4 года назад
thank you so much!!!
@daniyarkubashev7042
@daniyarkubashev7042 3 года назад
Thanks a loooot, + respect
@MrKracx
@MrKracx 3 года назад
no problem hinata
@orestdymarchuk2910
@orestdymarchuk2910 2 года назад
Thanks for great explanation 🇺🇦🇺🇦❤️
Далее
Java HashMap 🗺️
13:05
Просмотров 81 тыс.
Building the world's LARGEST iPhone
32:05
Просмотров 308 тыс.
I've been using Redis wrong this whole time...
20:53
Просмотров 356 тыс.
How to Implement a Hash Table in JavaScript
25:39
Просмотров 103 тыс.
How To Create Generics in C#, Including New Features
38:51
Set and HashSet in Java - Full Tutorial
20:43
Просмотров 214 тыс.
01. Internal Working of HashMap & Java-8 Enhancement
19:11