Paul Richard has Published 66 Articles

How can we RENAME an existing MySQL event?

Paul Richard

Paul Richard

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

174 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

199 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

14K+ 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

108 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

288 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

152 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

107 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

151 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

Double brace initialization in Java

Paul Richard

Paul Richard

Updated on 21-Jun-2020 12:59:12

401 Views

Double braces can be used to create and initialize objects in a single Java expression. See the example below −Exampleimport java.util.ArrayList; import java.util.List; public class Tester{    public static void main(String args[]) {       List list = new ArrayList();       list.add("A");     ... Read More

Do we need forward declarations in Java?

Paul Richard

Paul Richard

Updated on 21-Jun-2020 12:43:56

690 Views

Forward declarations means the declaration of a method or variable prior to its implementation. Such declaration is necessary in C/C++ programming language in order to be able to use a variable or object before its implementation. In case, if we want to use a library code, then we need to ... Read More

Advertisements