Differences between HashMap and Hashtable in Java

What are the differences between two similar Java classes? Check this article to find out
15 August 2017   1090

What is HashMap? 

The HashMap class uses a hash table to store the card, providing a fast execution time for the get() and put() queries for large sets. The class implements the Map interface (data storage in the form of key / value pairs). Keys and values can be of any type, including null. All keys must necessarily be unique, and the values can be repeated. This implementation does not guarantee the order of the elements.

Example:

// K - Key, V - Value
class HashMap<K, V>

You can declare it as follows:

Map<String, Integer> hashMap = new HashMap<String, Integer>();

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

What is Hashtable? 

Hashtable class implements a hashtable, which maps keys to values. It inherits Dictionary class and implements the Map interface.

Main Hashtable features:

  • A Hashtable is an array of list. Each list is known as a bucket. The position of bucket is identified by calling the hashcode() method. A Hashtable contains values based on the key.
  • It contains only unique elements.
  • It may have not have any null key or value.
  • It is synchronized.

Differences between HashMap and Hashtable

After our research, we've found out that there are 3 main differences:

  1. Hashtable is synchronized, and HashMap is not. Due to this fact, HashMap is better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.

  2. Hashtable does not allow null keys or values and HashMap allows one null key and any number of null values.

  3. One of HashMap's subclasses is LinkedHashMap, so in the event that you'd want predictable iteration order (which is insertion order by default), you could easily swap out the HashMap for a LinkedHashMap. This wouldn't be as easy if you were using Hashtable.

Google to Release Cloud Inference API

Cloud Inference API can be used for real time big data analysis 
20 September 2018   95

Google introduced an alpha version of the service for time series analysis. It processes information about events at the time - clicks, requests, activations of IoT devices, and so on. The Cloud Inference API analyzes these data in real time, finds correlations and makes predictions based on it.

Cloud Inference API
Cloud Inference API 

Service features:

  • A simple tree-like query language that allows you to specify your own time markers.
  • Online processing of incoming data with minimal delay. Therefore, Google recommends using the API in interactive user applications.
  • Ability to process data arrays of different volumes (up to trillions of records) and work under high load (up to hundreds of thousands of requests per second).
  • Full integration with Google Cloud Storage, which provides access to the same data in different services of the platform.
  • More information about the work of the tool can be found in the documentation.

Google noted that the service will be useful for a wide range of industries. Retailers can analyze the impact of pedestrian traffic on the level of sales conversion, content providers - the popularity of materials to provide better personal recommendations.

Now the Cloud Inference API is already being used by Snap to analyze the data received through the Snapchat application.

Google Cloud is developing a number of cloud services. At the end of August 2018, the company updated the tools for converting speech to text and vice versa. Cloud Text-to-Speech received support for several new languages ​​and voices, and Cloud Speech-to-Text - recognition of several speakers, language and the ability to highlight important words