Member-only story

Learning about Hash Table in Java Programming/Coding

Bryant Jimin Son
4 min readAug 15, 2020

--

Learning about Hash Table in Programming/Coding

Java’s Collection Class has a number of different data structures, but we will explore Hash Table. Why do we need Hash Table? And what is the characteristic of Hash Table? Before going further, though, let’s review other data structures: Array and Linked List.

Array

The biggest strength of array is that the value can be easily retrieved using index. For example, let’s suppose that an user asked for you to create an application that can manage the names for fruits. So, to test out of water, you decided to declare an array named “sampleList” that can store the 10 String Objects.

String[] listFruit = new String[10];

And you hard-code the following values

listFruit[0] = "apple";
listFruit[1] = "carrot";
listFruit[2] = "orange";

sampleList has 3 Object data, and you can recall them using the indexes.

// Print out "apple" in first line and print out "orange" in 2nd line
System.out.println(listFruit[0]);
System.out.println(listFruit[2]);

As you can observe, the biggest benefit of using array is to easily recall the values using index. But we see a problem here. The simple example worked for now because we just restrict the size to 10 objects. But the requirement states that the…

--

--

Bryant Jimin Son
Bryant Jimin Son

Written by Bryant Jimin Son

A cloud practitioner talking about technology, travels & career tips. But I will sometimes cover financial advises and some random stuffs.

No responses yet