Samual Sam has Published 2492 Articles

How to keep the insertion order with Java LinkedHashMap?

Samual Sam

Samual Sam

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

147 Views

To keep the insertion order with LinkedHashMap, use Iterator. Let us first create a HashMap and add elements to it −LinkedHashMaplHashMap = new LinkedHashMap(); lHashMap.put("1", "A"); lHashMap.put("2", "B"); lHashMap.put("3", "C"); lHashMap.put("4", "D"); lHashMap.put("5", "E"); lHashMap.put("6", "F"); lHashMap.put("7", "G"); lHashMap.put("8", "H"); lHashMap.put("9", "I");Now, get the values with the values() method. Iterate ... Read More

How to achieve case sensitive uniqueness and case insensitive search in MySQL?

Samual Sam

Samual Sam

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

969 Views

You can achieve case sensitive uniqueness and case insensitive search with the help of the following two ways −VARBINARY data type_bin collationVARBINARY data typeTo work with the VARBINARY data type, let us first create a table. The query to create a table is as follows −mysql> create table SearchingDemo2 ... Read More

LocalTime toString() method in Java

Samual Sam

Samual Sam

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

494 Views

The string value of the LocalTime object can be obtained using the method toString() in the LocalTime class in Java. This method requires no parameters and it returns the string value of the LocalTime object.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { ... Read More

Java Program to read map by Map.Entry

Samual Sam

Samual Sam

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

94 Views

To read the Map, first use getProperties() ad then iterator to iterate through the entire list of Map −Properties prop = System.getProperties(); Iterator i = prop.entrySet().iterator();Now, loop through Map.Entry and get the key-value pair for the Map −while (i.hasNext()) {    Map.Entry entry = (Map.Entry) i.next();    System.out.println(entry.getKey() + " ... Read More

Provider getProperty() method in Java

Samual Sam

Samual Sam

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

282 Views

A specific key can be used to search for the required property in the property list using the method getProperty() in the class java.security.Provider. This method requires a single parameter i.e. the key required to search for the property. It returns the property value for the key or returns null ... Read More

LocalTime withNano() method in Java

Samual Sam

Samual Sam

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

38 Views

An immutable copy of a LocalTime with the nanoseconds altered as required is done using the method withNano() in the LocalTime class in Java. This method requires a single parameter i.e. the nanosecond that is to be set in the LocalTime and it returns the LocalTime with the nanosecond altered ... Read More

Global memory management in C++ : Stack or Heap?

Samual Sam

Samual Sam

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

2K+ Views

Stack and heap are used to store variables during the execution of the program and it also get destroyed.Global data structures or global variables are not consumed by stack or heap. They basically allocated in a fixed memory block, which remains unchanged.int a[10]; // located in a fixed memory block ... Read More

LocalTime toSecondOfDay() method in Java

Samual Sam

Samual Sam

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

36 Views

The time in the form of seconds of the day can be obtained using the toSecondOfDay() method in the LocalTime class in Java. This method requires no parameters and it returns the time in the form of seconds of the day.A program that demonstrates this is given as follows −Example Live ... Read More

C++ Program to Implement Hash Tables Chaining with List Heads

Samual Sam

Samual Sam

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

461 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.This is a C++ Program to Implement Hash Tables Chaining with List Heads.AlgorithmFor insert:Begin ... Read More

Java Program to convert positive int to negative and negative to positive

Samual Sam

Samual Sam

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

8K+ Views

To convert positive int to negative and vice-versa, use the Bitwise Complement Operator.Let us first initialize a positive int −int positiveVal = 200;Now, let us convert it to negative −int negativeVal = (~(positiveVal - 1));Now, let’s say we have the following negative int −int negativeVal = -300;The following will convert ... Read More

Advertisements