Paul Richard has Published 74 Articles

Double brace initialization in Java

Paul Richard

Paul Richard

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

322 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

455 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

Difference between TreeMap, HashMap, and LinkedHashMap in Java

Paul Richard

Paul Richard

Updated on 21-Jun-2020 12:35:10

11K+ Views

HashMap, TreeMap and LinkedHashMap all implements java.util.Map interface and following are their characteristics.HashMapHashMap has complexity of O(1) for insertion and lookup.HashMap allows one null key and multiple null values.HashMap does not maintain any order.TreeMapTreeMap has complexity of O(logN) for insertion and lookup.TreeMap does not allow null key but allow multiple ... Read More

While adding the numbers contained in quotes, how MySQL evaluates if we write non-numeric text between numbers of a string?

Paul Richard

Paul Richard

Updated on 20-Jun-2020 13:49:59

58 Views

Suppose if we are trying to add the numbers having non-numeric text between numbers of a string, then MySQL simply use the first number of that string to evaluate the addition along with a warning. Following example will exhibit this −Examplemysql> Select '1525 * 2' + '200'As Total; +-------+ | ... Read More

How can we stuff a string with another one using MySQL functions?

Paul Richard

Paul Richard

Updated on 20-Jun-2020 13:05:02

269 Views

MySQL have two functions namely LPAD() and RPAD() with the help of which we can stuff a string with another string.LPAD() function, as the name suggests, left stuff a string with another string. Following is the syntax for using it in MySQL −SyntaxLPAD(original_string, @length, pad_string)Here,  original_string is the string in ... Read More

How can I use RAND() function in an ORDER BY clause to shuffle MySQL set of rows?

Paul Richard

Paul Richard

Updated on 20-Jun-2020 13:02:41

296 Views

When we use MySQL ORDER BY clause with RAND() function then the result set would have the shuffled set of rows. In other words, the result set would be in a random order. To understand it considers a table ‘Employee’ having the following records −mysql> Select * from employee; +----+--------+--------+ ... Read More

How can we use MySQL SELECT statement to count number of rows in a table?

Paul Richard

Paul Richard

Updated on 20-Jun-2020 06:29:06

189 Views

We need to use COUNT(*) function with SELECT clause to count the total number of rows in a table.Examplemysql> Select COUNT(*) from Student; +----------+ | COUNT(*) | +----------+ | 4        | +----------+ 1 row in set (0.06 sec)The query above counts the total number of ... Read More

How can I define a column of a MySQL table PRIMARY KEY without using the PRIMARY KEY keyword?

Paul Richard

Paul Richard

Updated on 19-Jun-2020 11:52:12

198 Views

As we know that a PRIMARY KEY column must have unique values and cannot have null values hence if we will define a column with UNIQUE and NOT NULL constraint both then that column would become PRIMARY KEY column.ExampleIn this example, we have created a table ‘Student123’ by defining column ... Read More

Semicolons in C++

Paul Richard

Paul Richard

Updated on 19-Jun-2020 05:27:03

808 Views

According to the ISO C++ specifications, The lexical representation of C++ programs includes a number of preprocessing tokens which are used in the syntax of the preprocessor or are converted into tokens for operators and punctuators. The semicolon is a punctuator in C++.A semicolon character is at the end of ... Read More

How to get Natural logarithm of 2 in JavaScript?

Paul Richard

Paul Richard

Updated on 18-Jun-2020 08:26:00

189 Views

To get the Natural logarithm of 2, use the Math.LN2 property in JavaScript. It returns the natural logarithm of 2, which is approximately 0.693.ExampleYou can try to run the following code to get Natural logarithm of 2 −Live Demo           JavaScript Math LN2 Property     ... Read More

Advertisements