Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Java Data Analysis

You're reading from   Java Data Analysis Data mining, big data analysis, NoSQL, and data visualization

Arrow left icon
Product type Paperback
Published in Sep 2017
Publisher Packt
ISBN-13 9781787285651
Length 412 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
John R. Hubbard John R. Hubbard
Author Profile Icon John R. Hubbard
John R. Hubbard
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Introduction to Data Analysis FREE CHAPTER 2. Data Preprocessing 3. Data Visualization 4. Statistics 5. Relational Databases 6. Regression Analysis 7. Classification Analysis 8. Cluster Analysis 9. Recommender Systems 10. NoSQL Databases 11. Big Data Analysis with Java A. Java Tools Index

Hash tables

A dataset of key-value pairs is usually implemented as a hash table. It is a data structure in which the key acts like an index into the set, much like page numbers in a book or line numbers in a table. This direct access is much faster than sequential access, which is like searching through a book page-by-page for a certain word or phrase.

In Java, we usually use the java.util.HashMap<Key,Value> class to implement a key-value pair dataset. The type parameters Key and Value are specified classes. (There is also an older HashTable class, but it is considered obsolete.)

Here is a data file of seven South American countries:

Hash tables

Figure 2-1 Countries data file

Here is a Java program that loads this data into a HashMap object:

Hash tables

Listing 2-1 HashMap example for Countries data

The Countries.dat file is in the data folder. Line 15 instantiates a java.io.File object named dataFile to represent the file. Line 16 instantiates a java.util.HashMap object named dataset. It is structured to have...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime