HashMap in Java

What is HashMap A HashMap is a simple yet powerful way to store and get data. HashMap is based on HashTable implementation, that implements the Map interface and stores items as key/value pairs. HashMap permits only unique keys. It also permits only one null key (whereas HashTable does not allow any null key) but may have more than one null…

ConcurrentHashMap in Java

Though we have thread-safe collections classes like HashTable, Synchronized Map, which can be used in multi-threaded environment but there are significant differences between them, which arise from the fact that how they achieve their thread-safety. All methods of Hashtable are synchronized which make them quite slow due to the number of thread increases. Synchronized Map is also similar to the…

Java forEach Example Using Lambda Expression

Introduction This tutorial will show you how to use Java 8 forEach() loop to iterate Collection using Lambda Expression. Prior to Java 8 or JDK 8, the for loop was used as a for-each style but in Java 8 the inclusion of forEach() loop simplifies the iteration process in mainly one line.

Convert file data to map-payload and insert into MySQL using Mule ESB

This tutorial will show you how to use Mule JDBC Transport to convert text file data to Map and insert into MySQL database in Mule based application. You may also review Mule JDBC Insert Example and Dump CSV data into MySQL Database using Mule ESB Connectors provide an abstraction layer over data transport mechanisms. Connectors exist for things such as…

Spring NamedParameterJdbcTemplate And Collections.singletonMap Example

NamedParameterJdbcTemplate and Collections.singletonMap In this post I will show you how to use NamedParameterJdbcTemplate and Collections.singletonMap to execute query for returning result. The NamedParameterJdbcTemplate class adds support for programming JDBC statements using named parameters, as opposed to programming JDBC statements using only classic placeholder (?) arguments. The NamedParameterJdbcTemplate class wraps a JdbcTemplate, and delegates to the wrapped JdbcTemplate to do…

Spring NamedParameterJdbcTemplate and MapSqlParameterSource Example

Introduction In this post I will show you how to use NamedParameterJdbcTemplate and MapSqlParameterSource to execute query for inserting or retrieving results from database table. The NamedParameterJdbcTemplate class adds support for programming JDBC statements using named parameters, as opposed to programming JDBC statements using only classic placeholder (?) arguments. An SqlParameterSource is a source of named parameter values to a…

Cucumber Data Table – Convert a Three Column Table to a List

Introduction Here in this post you will see an example on Cucumber data table – convert a three column table to a list. Cucumber is a tool for running automated acceptance tests written in a behavior-driven development (BDD) style. Cucumber is written in the Ruby programming language. Cucumber projects are available for other platforms beyond Ruby. Cucumber works with Ruby,…

Cucumber Data Table – Convert a Two Column Table to a Map

Introduction In this post you will see an example on cucumber data table – convert a two column table to a Map. Cucumber is a tool for running automated acceptance tests written in a behavior-driven development (BDD) style. Cucumber is written in the Ruby programming language. Cucumber projects are available for other platforms beyond Ruby. Cucumber works with Ruby, Java,…

REST Service with MultivaluedMap using Jersey

Introduction Here I am going to give an example on how MultivaluedMap in REST web service works. A MultivaluedMap<K, V> is a map of key-values pairs. Each key can have zero or more values, where K – the type of keys maintained by this map and V – the type of mapped values. The most important concept in REST is…

How HashMap Works In Java

Introduction HashMap (also known as HashTable) is, a data structure that can map keys to values, used to implement an associative array. A HashMap uses a hash function to compute an index into an array of buckets or slots, from which the correct value can be found. Ideally, the hash function will assign each key to a unique bucket, but…