Samual Sam has Published 2492 Articles

What is the easiest way to store date in MySQL database?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

187 Views

To store date in MySQL, use the STR_TO_DATE() method −insert into yourTableName values(STR_TO_DATE('yourDate', '%d/%m/%Y'));Let us first create a table −mysql> create table DemoTable (    AdmissionDate date ); Query OK, 0 rows affected (0.62 sec)Insert records in the table using insert command −mysql> insert into DemoTable values(STR_TO_DATE('10/01/2013', '%d/%m/%Y')); Query OK, ... Read More

Java Program to convert HashMap to TreeMap

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

185 Views

To convert HashMap to TreeMap, let us first create a Map with key-value pair −Mapmap = new HashMap(); map.put("1", "A"); map.put("2", "B"); map.put("3", "C"); map.put("4", "D"); map.put("5", "E"); map.put("6", "F"); map.put("7", "G");Now, convert the above HashMap to TreeMap −Mapsorted = new TreeMap(map);Example Live Demoimport java.util.HashMap; import java.util.Map; import java.util.TreeMap; public class ... Read More

How to use pollFirst() in android ConcurrentLinkedDeque?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

72 Views

Before getting into an example, we should know what ConcurrentLinkedDeque is, it is unbounded deque based on linked nodes. Multiple threads can access deque elements with safety.This example demonstrates about How to use pollFirst() in android ConcurrentLinkedDequeStep 1 − Create a new project in Android Studio, go to File ⇒ ... Read More

Implementing own Hash Table with Open Addressing Linear Probing in C++

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

874 Views

A hash table is a data structure which is used to store key-value pairs. Hash function is used by hash table to compute an index into an array in which an element will be inserted or searched.Linear probing is a collision resolving technique in Open Addressed Hash tables. In this ... Read More

Java Program to get Sub Map from TreeMap

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

68 Views

To get Sub Map from TreeMap, let us first create a TreeMap and set key-value pair −TreeMaptMap = new TreeMap(); tMap.put("1", "A"); tMap.put("2", "B"); tMap.put("3", "C"); tMap.put("4", "D"); tMap.put("5", "E"); tMap.put("6", "F"); tMap.put("7", "G");Now, let’s say you need to get submap from 3 to 7. For that, use the method ... Read More

How to use pool() in android LinkedBlockingDeque?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

72 Views

Before getting into an example, we should know what LinkedBlockingDeque is. It is implemented by Collection interface and the AbstractQueue class. It provides optional boundaries based on linked nodes.It going to pass memory size to a constructor and helps to provide memory wastage in android.This example demonstrates about How to ... Read More

Checking if a HashSet contains certain value in Java

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

678 Views

Let’s say the following is our Integer array −Integer arr[] = { 50, 100, 150, 200, 250, 300 };Set the above integer array in HashSet −Setset = new HashSet(Arrays.asList(arr));Now, let us check whether the HashSet contains certain value or not −set.contains(150)TRUE is returned if the value is in the List, ... Read More

How to use pool() in android ConcurrentLinkedQueue?

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

70 Views

Before getting into an example, we should know what ConcurrentLinkedQueue is, it is an unbounded queue based on linked nodes. Multiple threads can access queue elements with safety. Elements travel based on queue strategy as FIFO and elements going to insert from a tail. It does not allow null values.This ... Read More

Java Program to initialize a HashMap with Lambda Expressions

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

906 Views

To initialize a HashMap with Lambda, at first create a HashMpa and use Callable −HashMapmap = newHashMap()For key-value pair, you need to initialize them in the following way −HashMapmap = newHashMap() {    {       put(0, () -> {          return 10;       ... Read More

LocalDate isAfter() method in Java

Samual Sam

Samual Sam

Updated on 30-Jul-2019 22:30:25

1K+ Views

It can be checked if a particular LocalDate is after the other LocalDate in a timeline using the isAfter() method in the LocalDate class in Java. This method requires a single parameter i.e. the LocalDate object that is to be compared. It returns true if the LocalDate object is after ... Read More

Advertisements