The contains() method of CopyOnWriteArrayList in Java

Ankith Reddy
Updated on 30-Jul-2019 22:30:25
The contains() method of the CopyOnWriteArrayList class is used to get the specified element. It returns TRUE if the element is in the List, else FALSE is returned.The syntax is as followsboolean contains(Object ob)Here, ob is the element to be checked for existence. To work with CopyOnWriteArrayList class, you need to import the following packageimport java.util.concurrent.CopyOnWriteArrayList;The following is an example to implement CopyOnWriteArrayList class contains() method in JavaExample Live Demoimport java.util.concurrent.CopyOnWriteArrayList; public class Demo {    public static void main(String[] args) {       CopyOnWriteArrayList arrList = new CopyOnWriteArrayList();       arrList.add(100);       arrList.add(250);       ... Read More

LocalTime query() Method in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25
The LocalTime object can be queried as required using the query method in the LocalTime class in Java. This method requires a single parameter i.e. the query to be invoked and it returns the result of the query.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; import java.time.temporal.*; public class Demo {    public static void main(String[] args) {       LocalTime lt = LocalTime.parse("23:15:30");       System.out.println("The LocalTime is: " + lt);       String precision = lt.query(TemporalQueries.precision()).toString();       System.out.println("The Precision for the LocalTime is: "+ precision);    } }OutputThe LocalTime ... Read More

How to print dimensions of multidimensional array in C++

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25
Here is a C++ program to print dimensions of given array.AlgorithmHere template() function is used to find out the current size of array. Then recursively call it till the last dimension of array.Example Code Live Demo#include using namespace std; template void printDimensionsOfArray(const t (&a)[n]) {    cout

How to fix poor performance of INFORMATION_SCHEMA.key_column_usage in MySQL?

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25
You can use GLOBAL variable as shown below −SET global innodb_stats_on_metadata =0;After including the above syntax, the INFORMATION_SCHEMA.key_column_usage will take less time and that would improve the performance.The query is as follows −mysql> set global innodb_stats_on_metadata =0; Query OK, 0 rows affected (0.00 sec) mysql> SELECT REFERENCED_TABLE_NAME,TABLE_NAME,COLUMN_NAME,CONSTRAINT_SCHEMA -> FROM INFORMATION_SCHEMA.key_column_usage;The following is the output −It returns 674 rows in 0.28 seconds.

C++ Program to Implement Hash Tables Chaining with Doubly Linked Lists

Samual Sam
Updated on 30-Jul-2019 22:30:25
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 doubly linked lists.AlgorithmFor insert:Begin    Declare Function insert(int k, int v)       int hash_v= HashFunc(k)       HashTableEntry *en = ht[hash_v]       if (en == NULL)          en = new HashTableEntry          en->d = v          en->k = k ... Read More

Copy elision in C++

Nitya Raut
Updated on 30-Jul-2019 22:30:25
The Copy Elision is also known as the Copy Omission. This is one of the compiler optimization technique. It avoids the unnecessary copying of objects. Almost any current compiler uses this Copy Elision technique.Let us see how it works by the help of one example code:Example Code#include using namespace std; class MyClass {    public:       MyClass(const char* str = "\0") {  //default constructor          cout

Merge two tables with union in MySQL?

Smita Kapse
Updated on 30-Jul-2019 22:30:25
To merge two tables with UNION, you can use create table select statement. Following is the syntax −create table yourNewTableName select * from yourFirstTableName UNION select * from yourSecondTableName;Let us first create a table. Following is the query −mysql> create table FirstTable    -> (    -> Id int,    -> PersonName varchar(20)    -> ); Query OK, 0 rows affected (2.10 sec)Following is the query to insert some records in the table using insert command −mysql> insert into FirstTable values(10, 'Larry'); Query OK, 1 row affected (0.12 sec) mysql> insert into FirstTable values(20, 'David'); Query OK, 1 row ... Read More

What are the popular Crypto Currencies in circulation?

Prasanna Kotamraju
Updated on 30-Jul-2019 22:30:25
Bitcoin, invented by Satoshi Nakamoto in 2008 has ushered new waves in the field of cryptocurrencies. Inspired by Bitcoins and decentralized peer-to-peer network, there are many digital currencies that came into the world to change the global economy.Let us first understand what is a cryptocurrency? Cryptocurrencies are the digital currencies which are generated, stored and transacted digitally. The most important feature of cryptocurrency which makes it different from fiat currency is, that it is not created or maintained by any single central authority. It is created and maintained through a decentralized system which is maintained by the miners. The miners ... Read More

How to get the greatest of two columns values in MySQL?

Krantik Chavan
Updated on 30-Jul-2019 22:30:25
In order to get the greatest of two columns values in MySQL, you need to use GREATEST() function. Following is the syntax:select greatest(yourColumnName1, yourColumnName2) AS anyAliasName from yourTableName; Let us first create a table:mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Number1 int,    Number2 int ); Query OK, 0 rows affected (0.63 sec)Following is the query to insert some records in the table using insert command:mysql> insert into DemoTable(Number1, Number2) values(1000, 10000); Query OK, 1 row affected (0.49 sec) mysql> insert into DemoTable(Number1, Number2) values(600, 900); Query OK, 1 row affected (0.12 sec) mysql> ... Read More

What is that mysterious strong narrowband signal from constellation Sagittarius? What does it tell us?

Ishita K
Updated on 30-Jul-2019 22:30:25
A mysterious strong narrowband signal was received on August 15, 1977, by Big Ear Radio telescope in the United States, Ohio State University. The signal was recognized to have come from the constellation Sagittarius and had the hallmarks of coming from an extraterrestrial origin.Astronomer Jerry R. Ehman discovered the anomaly a few days later when he was reviewing the recorded data. The signal lasted for 72 seconds. He was excited by the result, circled the readings on the printout and wrote Wow! on its side. This is how the signal from constellation Sagittarius got its name of Wow!The Wow! signal is ... Read More
Advertisements