To add a new item to an array, you can use $push operator. Let us first implement the following query to create a collection with documents:> db.updateDemo.insertOne({"StudentName":"Larry", "StudentCoreSubject":["Java", "C"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c98ba78330fd0aa0d2fe4c9") } >db.updateDemo.insertOne({"StudentName":"Robert", "StudentCoreSubject":["C++", "MongoDB"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c98ba8b330fd0aa0d2fe4ca") } > db.updateDemo.insertOne({"StudentName":"Chris", "StudentCoreSubject":["Python"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c98ba9b330fd0aa0d2fe4cb") }Following is the query to display all the documents from a collection with the help of find() method> db.updateDemo.find().pretty();This will produce the following output{ "_id" : ObjectId("5c98ba78330fd0aa0d2fe4c9"), "StudentName" : "Larry", "StudentCoreSubject" : [ ... Read More
To make an http request in iOS we’ll make use of DataTask and sessions. We’ll create configuration, sessions, url, request, and dataTask objects. Let’s see the steps that we’ll go through.The HTTP request can be of different types, it depends on what kind of request we want to make to our server. Below are the basic types of requests.“GET”, ”POST”, ”PUT”, ”DELETE” , we can make use of any of these according to our API. The basics remain same for each kind of request, which are shown below. Let’s see these examples with DELETE type of request.First of all we ... Read More
If a directed graph is given, determine if a vertex j is reachable from another vertex i for all vertex pairs (i, j) in the given graph. Reachable mean that there is a path from vertex i to j. This reach-ability matrix is called transitive closure of a graph. Warshall algorithm is commonly used to find the Transitive Closure of a Given Graph G. Here is a C++ program to implement this algorithm.AlgorithmBegin 1. Take maximum number of nodes as input. 2. For Label the nodes as a, b, c….. 3. To check if there any edge ... Read More
A Hamiltonian cycle is a Hamiltonian Path such that there is an edge (in graph) from the last vertex to the first vertex of the Hamiltonian Path. It is in an undirected graph is a path that visits each vertex of the graph exactly once.Functions and purposesBegin 1. function isSafe() is used to check for whether it is adjacent to the previously added vertex and already not added. 2. function hamiltonianCycle() solves the hamiltonian problem. 3. function hamCycle() uses hamiltonianCycle() to solve the hamiltonian problem. It returns false if there is no Hamiltonian Cycle possible, ... Read More
Before we even start discussing the space and weight constraints of a laptop, many customized/personalized Apps Have Arrived: a touch bar therefore, is a strip of touch-sensitive, context-aware display that replaces the function keys seen in a traditional keyboard.Applications for EventsFor example, in Apple iPhones, the App called ‘Siri’ is also a permanent addition to the touch bar and it is located on the far right-hand side. There are others who state that Windows 10 S is the future of the desktop PC. The Desktop PC which was at one point considered a novelty is now more of an obsolete piece ... Read More
Unfortunately, in the Indian education system, we are more concerned about scores on the exams rather than the knowledge. We consider that grades are the only measure of college success. In some sense that is also true because of the competition in the job market.Let us look at some tips to score well in college exams:Since you are out of high school, the first thing you have to learn is taking charge of your life. So step up to bat and take responsibility.Pick up the right courses. Make a balance between the interesting and scoring subjects. But take care that ... Read More
The fixed instant on the clock can be obtained using the method fixed() in the Clock Class in Java. This method requires two parameters i.e. the fixed instant and the time zone. Also, it returns the fixed instant on the clock. The fixed() method is normally used for testing purposes.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); ZoneId zId = ZoneId.of("Australia/Melbourne"); ... Read More
With JSP program, it is very easy to get the current date and the time. You can use a simple Date object with the toString() method to print the current date and the time as follows −Example Live Demo Display Current Date & Time Display Current Date & Time Let us now keep the code in CurrentDate.jsp and then call this JSP using the URL http://localhost:8080/CurrentDate.jsp. You will receive the following result −OutputDisplay ... Read More
It can be checked if the duration is negative or not using the isNegative() method in the Duration class in Java. This method requires no parameters. Also, it returns true if the duration is negative and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.Duration; public class Demo { public static void main(String[] args) { Duration d = Duration.ofSeconds(5); boolean flag = d.isNegative(); System.out.println("The duration is: " + d); if(flag) System.out.println("The above duration is negative"); else ... Read More
The IntStream min() method in the Java IntStream class is used to get the minimum element from the stream. It returns an OptionalInt describing the minimum element of this stream, or an empty optional if this stream is empty.The syntax is as followsOptionalInt min()Here, OptionalInt is a container object which may or may not contain an int value.Create an IntStream and add some elementsIntStream intStream = IntStream.of(89, 45, 67, 12, 78, 99, 100);Now, get the minimum element of the streamOptionalInt res = intStream.min();The following is an example to implement IntStream min() method in Java. The isPresent() method of the OptionalInt ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP