Articles on Trending Technologies

Technical articles with clear explanations and examples

How to compare field values in MongoDB?

George John
George John
Updated on 30-Jul-2019 333 Views

You can use $where operator to compare field values in MongoDB. Let us first create a collection with documents> db.comparingFieldDemo.insertOne({"Value1":30, "Value2":40}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9c99ed2d6669774125246e") } > db.comparingFieldDemo.insertOne({"Value1":60, "Value2":70}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9c99f62d6669774125246f") } > db.comparingFieldDemo.insertOne({"Value1":160, "Value2":190}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9c99ff2d66697741252470") } > db.comparingFieldDemo.insertOne({"Value1":200, "Value2":160}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9c9a0b2d66697741252471") }Following is the query to display all documents from a collection with the help of find() method> db.comparingFieldDemo.find().pretty();This will produce the following output{    "_id" : ObjectId("5c9c99ed2d6669774125246e"),    "Value1" : 30, ...

Read More

Java Program to convert java.util.Date to LocalDate

Samual Sam
Samual Sam
Updated on 30-Jul-2019 332 Views

At first set the date with java.util.Date −java.util.Date date = new Date();Now, convert the date to LocalDate −Instant instant = Instant.ofEpochMilli(date.getTime()); System.out.println("LocalDate = "+LocalDateTime.ofInstant(instant, ZoneId.systemDefault()).toLocalDate());Example Live Demoimport java.time.Instant; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.Date; public class Demo {    public static void main(String[] args) {       java.util.Date date = new Date();       System.out.println("Date = "+date);       Instant instant = Instant.ofEpochMilli(date.getTime());       System.out.println("LocalDate = "+LocalDateTime.ofInstant(instant, ZoneId.systemDefault()).toLocalDate());    } }OutputDate = Thu Apr 18 23:51:06 IST 2019 LocalDate = 2019-04-18

Read More

8085 Program to simulate decimal up counter

George John
George John
Updated on 30-Jul-2019 2K+ Views

Now let us see a program of Intel 8085 Microprocessor. In this program we will see how to simulate the decimal up counter.Problem Statement:Write 8085 Assembly language program to simulate decimal up counter.Discussion:In this section we are simulating the decimal up counter. Here the counter will count 100 decimal numbers from 0 to 99. All values will be updated in each 0.5 seconds. For decimal count we are using the DAA instruction.Note: Here for simplicity we are storing the numbers into memory. To simulate it like a counter we can use 7-segment display to show the numbersInput:Here we are not ...

Read More

General purpose registers in 8086 microprocessor

Ankith Reddy
Ankith Reddy
Updated on 30-Jul-2019 16K+ Views

The general purpose registers are used to store temporary data in the time of different operations in microprocessor. 8086 has eight general purpose registers. The description of these general purpose registersRegisterFunctionAXThis is the accumulator. It is 16-bit registers, but it is divided into two 8-bit registers. These registers are AH and AL. AX generally used for arithmetic or logical instructions, but it is not mandatory in 8086.BXBX is another register pair consisting of BH and BL. This register is used to store the offset values.CXCX is generally used as control register. It has two parts CH and CL. For different looping ...

Read More

C++ Program to Search Sorted Sequence Using Divide and Conquer with the Aid of Fibonacci Numbers

George John
George John
Updated on 30-Jul-2019 620 Views

In this C++ program we implement a Divide and Conquer approach using Fibonacci numbers. Using Fibonacci numbers, we calculate mid of data array to search the data item. The time complexity of this approach is O(log(n)).AlgorithmBegin    Assign the data to the array in a sorted manner.    Take input of the element to be searched.    Call FibonacciSearch() function.    Calculate the mid value using ‘start+fib[index-2]’ expression.    If the chosen item is equal to the value at mid index, print result and return to main.    If it is lesser than the value at mid index, proceed with ...

Read More

How many types of directive tags JSP supports?

karthikeya Boyini
karthikeya Boyini
Updated on 30-Jul-2019 252 Views

A JSP directive affects the overall structure of the servlet class. It usually has the following form −Directives can have a number of attributes which you can list down as key-value pairs and separated by commas.The blanks between the @ symbol and the directive name, and between the last attribute and the closing %>, are optional.There are three types of directive tag −S.No.Directive & Description1Defines page-dependent attributes, such as scripting language, error page, and buffering requirements.2Includes a file during the translation phase.3Declares a tag library, containing custom actions, used in the page

Read More

How to Reverse a linked list in android?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 258 Views

This example demonstrate about How to reverse a linked list 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.     In the above code, we have taken a text view to show the reverse of a linked list.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.LinkedList; public class MainActivity extends ...

Read More

Iterate through Octet Tuple in Java

Nishtha Thakur
Nishtha Thakur
Updated on 30-Jul-2019 192 Views

You can easily iterate through Octet Tuple using a for the loop. Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package −import org.javatuples.Octet;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples −Steps − How to run JavaTuples program in EclipseThe following is an example to ...

Read More

How to remove an element from a doubly-nested array in a MongoDB document?

Anvi Jain
Anvi Jain
Updated on 30-Jul-2019 2K+ Views

To remove an element from a doubly-nested array in MongoDB document, you can use $pull operator.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.removeElementFromDoublyNestedArrayDemo.insertOne(    ... {       ... "_id" : "1",       ... "UserName" : "Larry",       ... "UserDetails" : [          ... {             ... "UserCountryName" : "US",             ... "UserLocation" : [                ... { ...

Read More

Avoid duplicate entries in MongoDB?

Smita Kapse
Smita Kapse
Updated on 30-Jul-2019 1K+ Views

To avoid duplicate entries in MongoDB, you can use createIndex(). The syntax is as follows −db.yourCollectionName.createIndex({"yourFieldName":1}, {unique:true});Let us implement the above syntax. The query to avoid duplicate entries in MongoDB is a follows −> db.avoidDuplicateEntriesDemo.createIndex({"UserName":1}, {unique:true}); {    "createdCollectionAutomatically" : true,    "numIndexesBefore" : 1,    "numIndexesAfter" : 2,    "ok" : 1 }Now insert some records in the above collection. The query to insert record is as follows −> db.avoidDuplicateEntriesDemo.insertOne({"UserName":"John"}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c90e1824afe5c1d2279d697") }Here is the error whenever you try to insert the same record once again −> db.avoidDuplicateEntriesDemo.insertOne({"UserName":"John"}); 2019-03-19T18:03:08.465+0530 E QUERY [js] ...

Read More
Showing 59381–59390 of 61,248 articles
Advertisements