The dot and arrow operator are both used in C++ to access the members of a class or structure. They are just used in different scenarios. In C++, types declared as class, struct, or union are considered "of class type". So the following refers to all three of them.a.b is only used if b is a member of the object (or reference to an object) a. So for a.b, a will always be an actual object (or a reference to an object) of a class.a->b is essentially a shorthand notation for (*a).b, i.e., if a is a pointer to an ... Read More
To remove object from an array in MongoDB, you can use $pull operator. The syntax is as follows:db.yourCollectionName.update( {'_id':ObjectId("5c6ea036a0c51185aefbd14f")}, {$pull:{"yourArrayName":{"yourArrayFieldName":yourValue}}}, false, true);To understand the above syntax, let us create a collection with document. The query to create a collection with document is as follows:> db.removeObject.insertOne({"CustomerName":"Maxwell", "CustomerAge":23, ... "CustomerDetails":[ ... { ... "CustomerId":100, ... "CustomerProduct":"Product-1" ... }, ... { ... "CustomerId":150, ... "CustomerProduct":"Product-2" ... }, ... { ... "CustomerId":200, ... "CustomerProduct":"Product-3" ... } ... ] ... }); { "acknowledged" : true, "insertedId" : ObjectId("5c6ea036a0c51185aefbd14f") }Display all documents from a collection with the help of find() method. The query is ... Read More
The JspWriter object contains most of the same methods as the java.io.PrintWriter class. However, JspWriter has some additional methods designed to deal with buffering. Unlike the PrintWriter object, JspWriter throws IOExceptions.
You can insert date values in SQL using the date datatype, The java.sql.Date class maps to the SQL DATE type.The PreparedStatement interface provides a method named setDate(). Using this you can insert date into a table. This method accepts two parameters −An integer representing the parameter index of the place holder (?) to which we need to set date value.a Date object representing the date value to be passed. The constructor of java.sql.Date class accepts a variable of long type representing the number of milliseconds from the epoch (standard base time I.e. January 1, 1970, 00:00:00 GMT).ExampleAssume we have created ... Read More
The indexOf() method of the CopyOnWriteArrayList class is used to get the index of the first occurrence of an element. The method has two two forms. Let us see them one by oneindexOf(Object o) methodThe indexOf(Object o) is used to get the index of the first occurrence of an element.The syntax is as followsindexOf(Object o)Here, o is the element for which you want the index. 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 indexOf() method in JavaExample Live Demoimport java.util.concurrent.CopyOnWriteArrayList; public class Demo { public static void ... Read More
The concat() method of the DoubleStream class creates a stream which is concatenated. The elements of the resultant stream are all the elements of the first stream followed by all the elements of the second stream.The syntax is as follows.static DoubleStream concat(DoubleStream streamOne, DoubleStream streamTwo)Here, streamOne is the first stream whereas streamTwo is the second stream.To use the DoubleStream class in Java, import the following package.import java.util.stream.DoubleStream;Create a DoubleStream with some elements.DoubleStream doubleStream1 = DoubleStream.of(20.5, 30.6, 58.9, 66.7);Create another DoubleStream.DoubleStream doubleStream2 = DoubleStream.of(71.8, 77.9, 82.3, 91.6, 98.4);Now, concat the streamsDoubleStream.concat(doubleStream1, doubleStream2)The following is an example to implement DoubleStream concat() method ... Read More
An immutable copy of a LocalTime object where some nanoseconds are added to it can be obtained using the plusNanos() method in the LocalTime class in Java. This method requires a single parameter i.e. the number of nanoseconds to be added and it returns the LocalTime object with the added nanoseconds.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalTime lt = LocalTime.now(); System.out.println("The current LocalTime is: " + lt); System.out.println("The LocalTime with 1000 nanoseconds added is: ... Read More
In order to delete the collection which has some special characters like _ or -, you need to use the following syntax −db.getCollection("yourCollectionName").drop();To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.createCollection("_personalInformation"); { "ok" : 1 } > db.getCollection('_personalInformation').insertOne({"ClientName":"Chris", "ClientCountryName":"US"}); { "acknowledged" : true, "insertedId" : ObjectId("5c9158bb4afe5c1d2279d6b2") } > db.getCollection('_personalInformation').insertOne({"ClientName":"Mike", "ClientCountryName":"UK"}); { "acknowledged" : true, "insertedId" : ObjectId("5c9158c84afe5c1d2279d6b3") } > db.getCollection('_personalInformation').insertOne({"ClientName":"David", "ClientCountryName":"AUS"}); { "acknowledged" : true, "insertedId" : ObjectId("5c9158d54afe5c1d2279d6b4") }Display all documents from a collection with the ... Read More
You can get the number of columns of a table using the getColumnCount() method of the ResultSetMetaData class.//Retrieving the ResultSetMetaData object ResultSetMetaData rsmd = rs.getMetaData(); //getting the column type int column_count = rsmd.getColumnCount();Assume we have a table named employee_data in the database with description as shown below:+----------+--------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +----------+--------------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | Name | varchar(255) | YES | ... Read More
In this section we are going to develop a command line interface using python. But before we deep dive into program, lets first understand command line.Command line are in use since the existence of computer programs and are built on commands. A command line program is a program that runs from a shell or from a command lineWhile command line interface provides user interface that is navigated by typing commands at terminals, shells or consoles instead of using the mouse.A command-line interface(CLI) starts with an executable. There are parameters which we can pass to the script depending how they are ... Read More