This example demonstrate about How to remove duplicates from a sorted 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 text view to show without a duplicated sorted 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; import java.util.Stack; ... Read More
The LongStream builder() class in Java is used to return a builder for a LongStream.The syntax is as follows.static LongStream.Builder builder()Here, LongStream.Builder is a mutable builder for a LongStream.To use the LongStream class in Java, import the following package.import java.util.stream.LongStream;The following is an example to implement LongStream builder() method in Java.Example Live Demoimport java.util.stream.LongStream; public class Demo { public static void main(String[] args) { LongStream longStream = LongStream.builder().add(5).build(); longStream.forEach(System.out::println); } }Output5
Use $nin operator along with $elemMatch and $not for this. 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.combinationOfArrayDemo.insertOne({"StudentName":"Larry", "StudentAge":21, "StudentFavouriteTechnicalSubject":["C", "Java"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c7f77cc8d10a061296a3c58") } > db.combinationOfArrayDemo.insertOne({"StudentName":"Mike", "StudentAge":23, "StudentFavouriteTechnicalSubject":["C++", "Java"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c7f77dc8d10a061296a3c59") } > db.combinationOfArrayDemo.insertOne({"StudentName":"David", "StudentAge":22, "StudentFavouriteTechnicalSubject":["Java"]}); { "acknowledged" : true, "insertedId" : ObjectId("5c7f77f48d10a061296a3c5a") }Display all documents from a collection with the help of find() method. The query is as follows −> db.combinationOfArrayDemo.find().pretty();The following is the output ... Read More
You can use subquery for this. Let us first create a demo tablemysql> create table uniqueBothColumnValueSameDemo -> ( -> UserId int, -> UserValue int -> ); Query OK, 0 rows affected (0.64 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into uniqueBothColumnValueSameDemo values(10, 20); Query OK, 1 row affected (0.21 sec) mysql> insert into uniqueBothColumnValueSameDemo values(10, 20); Query OK, 1 row affected (0.09 sec) mysql> insert into uniqueBothColumnValueSameDemo values(20, 30); Query OK, 1 row affected (0.10 sec) mysql> insert into uniqueBothColumnValueSameDemo values(20, 40); Query OK, 1 row affected ... Read More
The set() method of the AbstractList class is used to replace the element at the specified position in this list with the specified element. It returns the element that gets replaced.The syntax is as follows:public E set(int index, E ele)Here, the parameter index is the index of the element to replace, whereas ele is the element to be stored at the specified position.To work with the AbstractList class, import the following package:import java.util.AbstractList;The following is an example to implement set() method of the AbstractlList class in Java:Example Live Demoimport java.util.LinkedList; import java.util.AbstractList; public class Demo { public static void main(String[] ... Read More
In order to connect to my table by command line, you need to use db commanddb.yourCollectionName.find();Let’s say we have a database “sample” with some collections. First check the current database> use sample; switched to db sample > db; Sample Now we have reached the database sample. The database “sample” is having the following collections: > show collections;This will produce the following outputarraySizeErrorDemo basicInformationDemo copyThisCollectionToSampleDatabaseDemo deleteAllRecordsDemo deleteDocuments deleteDocumentsDemo deleteSomeInformation documentWithAParticularFieldValueDemo employee findListOfIdsDemo findSubstring getAllRecordsFromSourceCollectionDemo getElementWithMaxIdDemo internalArraySizeDemo largestDocumentDemo makingStudentInformationClone oppositeAddToSetDemo prettyDemo returnOnlyUniqueValuesDemo selectWhereInDemo sourceCollection studentInformation sumOfValueDemo sumTwoFieldsDemo truncateDemo updateInformation userInformationHere is the correct way of connecting to a table i.e. collection. You ... Read More
You can use CURRENT_TIMESTAMP to set system date time. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, ClientFirstName varchar(20), ClientLastName varchar(20), ClientAge int ); Query OK, 0 rows affected (0.66 sec)Following is the query to set default datetime as system date time in MySQL −mysql> alter table DemoTable add column ClientProjectDeadline timestamp default current_timestamp; Query OK, 0 rows affected (0.46 sec) Records: 0 Duplicates: 0 Warnings: 0Let us check the description of table once again −mysql> desc DemoTable;This will produce the following output −+-----------------------+-------------+------+-----+-------------------+----------------+ | Field ... Read More
Now let us see a program of Intel 8085 Microprocessor. In this program we will see how to generate real time clock using 8085.Problem Statement:Write 8085 Assembly language program to simulate real-time clock.Discussion:In this program we are creating a real time clock using 8085MPU. Here we are generating 1s delay to update seconds. This clock is 24Hrs clock. We are initializing the clock from 00:00:00. To display the values into 7-segment display we have to use some Port ICs and correct configurations. In each 60 seconds the minute field is updated, and in each 60 minutes the hour field is ... Read More
These instructions are used to transfer the data from the source operand to the destination operand. These are also known as copy instructions.Let us see the data transfer instructions of 8086 microprocessor. Here the D and S are destination and source respectively. D and S can be either register, data or memory address.OpcodeOperandDescriptionMOVD, SUsed to copy the byte or word from the provided source to the provided destination.PUSHDUsed to put a word at the top of the stack.POPDUsed to get a word from the top of the stack to the provided location.PUSHA----Used to put all the registers into the stack.POPA----Used ... Read More
Before getting into an example, we should know what singleton design pattern is. A singleton is a design pattern that restricts the instantiation of a class to only one instance. Notable uses include controlling concurrency and creating a central point of access for an application to access its data store.This example demonstrates How to use singleton dialog in androidStep 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 ... Read More