Here we will see what will be the effect of explicit keyword in C++. Before discussing that, let us see one example code, and try to find out its output.Example#include using namespace std; class Point { private: double x, y; public: Point(double a = 0.0, double b = 0.0) : x(a), y(b) { //constructor } bool operator==(Point p2) { if(p2.x == this->x && p2.y == this->y) return true; return ... Read More
Let’s say both the numbers are 50 and 60. You can use below syntax −db.yourCollectionName.find({yourFieldName: { $gt : 50 , $lt : 60 } } );If you want to include 50 and 60 also then use below syntax −db.yourCollectionName.find({yourFieldName: { $gte : 50 , $lte : 60 } } );Let us first create a collection with documents −> db.returnEverythingBetween50And60.insertOne({"Amount":55}); { "acknowledged" : true, "insertedId" : ObjectId("5cd3c42eedc6604c74817cdb") } > db.returnEverythingBetween50And60.insertOne({"Amount":45}); { "acknowledged" : true, "insertedId" : ObjectId("5cd3c432edc6604c74817cdc") } > db.returnEverythingBetween50And60.insertOne({"Amount":50}); { "acknowledged" : true, "insertedId" : ObjectId("5cd3c436edc6604c74817cdd") } > db.returnEverythingBetween50And60.insertOne({"Amount":59}); { "acknowledged" : true, ... Read More
Yes, we can display a JTabPane with TextArea in one of the tabs. For that, let us first create a JTabbedPane component −JTabbedPane tabbedPane = new JTabbedPane();Now, create a text area you want to set under one of the tabs −JTextArea text = new JTextArea(100, 100);Now, set panels for the tabs. Under one of them, set the text area we created above as shown below −panel2 = new JPanel(); panel2.add(text); panel3 = new JPanel(); panel4 = new JPanel(); panel5 = new JPanel(); panel6 = new JPanel(); panel7 = new JPanel(); panel8 = new JPanel();Now, one by one create different tabs ... Read More
To enable scrolling tabs in a JTabbedPane container, use the setTabLayoutPolicy() method −tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);Above, we have set the constant to be SCROLL_TAB_LAYOUT, since we want the scroller to be visible when all the tabs won’t fit within a single run.The following is an example to enable scrolling tabs in a JTabbedPane container −Examplepackage my; import javax.swing.*; import java.awt.*; public class SwingDemo { public static void main(String args[]) { JFrame frame = new JFrame("Devices"); JTabbedPane tabbedPane = new JTabbedPane(); JTextArea text = new JTextArea(100, 100); JPanel panel1, panel2, panel3, ... Read More
The IN clause in MYSQL database is used to specify the list of parameters in a query.For example, you need to retrieve contents of a table using specific IDs you can do so using the SELECT statement along with the IN clause as −mysql> SELECT * from sales where ID IN (1001, 1003, 1005); +------+-------------+--------------+--------------+--------------+-------+------------+ | ID | ProductName | CustomerName | DispatchDate | DeliveryTime | Price | Location | +------+-------------+--------------+--------------+--------------+-------+------------+ | 1001 | Key-Board | Raja | 2019-09-01 | 11:00:00 | 8500 | Hyderabad ... Read More
For string matching, use LIKE operator. Let us first create a table −mysql> create table DemoTable -> ( -> MonthName varchar(100) -> ); Query OK, 0 rows affected (0.63 sec)Insert some records in the table using insert command −mysql> insert into DemoTable values('JFMA'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('JMA'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('JDN'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values('JFOSA'); Query OK, 1 row affected (0.19 sec)Display all records from the table using select statement ... Read More
Here we will see how we can find the absolute difference between the product of all prime numbers and all non-prime numbers of an array. To solve this problem, we have to check whether a number is prime or not. One possible way for primality testing is by checking a number is not divisible by any number between 2 to square root of that number. So this process will take 𝑂(√𝑛) amount of time. Then get the product and try to find the absolute difference.AlgorithmdiffPrimeNonPrimeProd(arr)begin prod_p := product of all prime numbers in arr prod_np := product of ... Read More
Here we will see what are the differences for set, multiset, unordered_set and unordered_multiset in C++. Let us see the properties of them using some example.SetThe properties of set are like belowStores data in sorted orderStores only unique valuesWe can insert or delete data, but cannot change the dataWe can remove more than one element using start and end iteratorWe can traverse using iteratorsSets are implemented using Binary Search TreeNow let us see an exampleExample#include #include using namespace std; main() { int data[15] = {11, 55, 22, 66, 33, 22, 11, 44, 77, 88, 66, 99, 66, 23, 41}; set my_set; for(int i = 0; i
This example demonstrate about How to display count of notifications in toolbar icon in Android.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project.Step 2 − Add the following code to res/layout/activity_main.xml. ... Read More
Let us first create some collections that starts from year number i.e. 2015, 2019, etc −> use web; switched to db web > db.createCollection("2015-myCollection"); { "ok" : 1 } > db.createCollection("2019-employeeCollection"); { "ok" : 1 } > db.createCollection("2015-yourCollection"); { "ok" : 1 }Now you can display all the collections with the help of SHOW −> show collections;This will produce the following output −2015-myCollection 2015-yourCollection 2019-employeeCollection applyConditionDemo check creatingAliasDemo emp_info emptyCollection removeNullDemoFollowing is the query to get all collections where collection name like ‘%2015%’ −> db.getCollectionNames().filter(function (v) { return /^2015\-/.test(v); })This will produce the following output −[ "2015-myCollection", "2015-yourCollection" ]If you ... Read More