Paul Richard has Published 74 Articles

What is the role of the window.history object in JavaScript?

Paul Richard

Paul Richard

Updated on 23-Jun-2020 08:00:51

148 Views

The window.history object is used to go back or to the next page of the web browser. It has the browser's history and comes with the following two methods −history.back − Go to previous URLhistory.next − Go to next URLExampleYou can try to run the following code to learn how ... Read More

How can we have multiple virtuals GENERATED COLUMNS in MySQL table with CREATE TABLE statement?

Paul Richard

Paul Richard

Updated on 22-Jun-2020 14:35:35

196 Views

It is quite possible to add multiple virtual generated columns in a MySQL table. It can be illustrated with the following example as follows −Examplemysql> Create table profit(cost int, price int, profit int AS (price-cost), price_revised int AS (price-2)); Query OK, 0 rows affected (0.73 sec) mysql> Describe profit; ... Read More

How can we RENAME an existing MySQL event?

Paul Richard

Paul Richard

Updated on 22-Jun-2020 12:33:25

116 Views

With the help of ALTER EVENT statement along with the RENAME keyword, we can RENAME an existing event. To illustrate it we are having the following example in which we are renaming the event ‘Hello’ to ‘Hello_renamed’ −Examplemysql> ALTER EVENT Hello RENAME TO Hello_renamed; Query OK, 0 rows affected (0.00 ... Read More

How to iterate any Map in Java?

Paul Richard

Paul Richard

Updated on 22-Jun-2020 11:34:18

136 Views

Following example uses iterator Method of Collection class to iterate through the HashMap.Example Live Demoimport java.util.*; public class Main {    public static void main(String[] args) {       HashMap< String, String> hMap = new HashMap< String, String>();       hMap.put("1", "1st");       hMap.put("2", "2nd");   ... Read More

How to compare two arrays in Java?

Paul Richard

Paul Richard

Updated on 22-Jun-2020 11:31:37

13K+ Views

Arrays can be compared using following ways in JavaUsing Arrays.equals(array1, array2) methods − This method iterates over each value of an array and compare using equals method.Using Arrays.deepEquals(array1, array2) methods − This method iterates over each value of an array and deep compare using any overridden equals method.Using == on ... Read More

How can I convert 1st January of the current year into epoch?

Paul Richard

Paul Richard

Updated on 22-Jun-2020 08:06:17

59 Views

It can be done by using UNIX_TIMESTAMP() function as follows −mysql> Select UNIX_TIMESTAMP(CONCAT(YEAR(CURDATE()), '-01-01')); +--------------------------------------------------+ | UNIX_TIMESTAMP(CONCAT(YEAR(CURDATE()), '-01-01')) | +--------------------------------------------------+ | 1483209000                                       | +--------------------------------------------------+ 1 row in set (0.03 sec)It can ... Read More

What are MySQL subqueries and its general categories?

Paul Richard

Paul Richard

Updated on 22-Jun-2020 08:01:50

145 Views

A subquery is best defined as a query within a query. Subqueries enable you to write queries that select data rows for criteria that are actually developed while the query is executing at runtime. More formally, it is the use of a SELECT statement inside one of the clauses of ... Read More

What is the advantage of CONCAT_WS() function over CONCAT() function when we want to concatenate the values from the column and any of the columns have NULL as its value?

Paul Richard

Paul Richard

Updated on 22-Jun-2020 07:31:18

105 Views

As we know that CONCAT() function returns NULL if any of the arguments is NULL but CONCAT_WS() function returns NULL only if the first argument i.e. the separator is NULL and it ignores any other NULL. We can say this is the advantage of CONCAT_WS() function over CONCAT() function when ... Read More

What happens if we provide NULL as an argument to MySQL CHAR() function?

Paul Richard

Paul Richard

Updated on 22-Jun-2020 06:11:23

61 Views

MySQL CHAR() function will ignore NULL if it is provided as an argument to it. To understand it, consider the following examples −mysql> Select CHAR(65, 66, 67, NULL); +---------------------+ | CHAR(65, 66, 67, NULL) | +---------------------+ | ABC                 | +---------------------+ 1 row ... Read More

Factory method to create Immutable Set in Java SE 9

Paul Richard

Paul Richard

Updated on 21-Jun-2020 13:58:41

81 Views

With Java 9, new factory methods are added to Set interface to create immutable instances. These factory methods are convenience factory methods to create a collection in less verbose and in concise way.Old way to create collectionsExampleimport java.util.Collections; import java.util.HashSet; import java.util.Set; public class Tester {    public static ... Read More

Advertisements