Find if Two Lists Contain Exactly the Same Elements in Java

Samual Sam
Updated on 30-Jul-2019 22:30:25

2K+ Views

Two lists are equal if they consist of same number of elements in the same order.Let’s say we have the following two lists −ListarrList1 = Arrays.asList(new Integer[] { 10, 20, 30, 45, 55, 70, 90, 100 }); ListarrList2 = Arrays.asList(new Integer[] {15, 25, 35, 50, 55, 75, 95, 120});Now, let’s find out whether both the lists are equal or not −arrList1.equals(arrList2);If both the above lists have equal elements, then TRUE is returned, else FALSE is the return value.Example Live Demoimport java.util.Arrays; import java.util.List; public class Demo {    public static void main(String[] a) {       ListarrList1 = Arrays.asList(new Integer[] ... Read More

Delete Last 4 Letters in MySQL

Samual Sam
Updated on 30-Jul-2019 22:30:25

154 Views

You can use SUBSTRING() along with UPDATE command to delete last 4 letters. Let us first create a table −mysql> create table DemoTable (    StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    StudentSubject varchar(100) ); Query OK, 0 rows affected (0.57 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentSubject) values('Introduction to Java'); Query OK, 1 row affected (0.14 sec) mysql> insert into DemoTable(StudentSubject) values('Introduction to C'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(StudentSubject) values('Introduction to C++'); Query OK, 1 row affected (0.11 sec) mysql> insert into DemoTable(StudentSubject) values('Spring And Hibernate'); ... Read More

Add Two 16-bit BCD Numbers with Carry in 8086

George John
Updated on 30-Jul-2019 22:30:25

3K+ Views

In this program we will see how to add two 16-bit BCD numbers with carry.Problem StatementWrite 8086 Assembly language program to add two 16-bit BCD numbers stored in memory offset 500H – 501H and 502H – 503H.DiscussionHere we are adding the 16-bit data byte by byte. At first we are adding lower byte and perform the DAA instruction, then Add higher bytes with carry, and again DAA to adjust. The final result is stored at location offset 600H, and if carry is present, it will be stored at 601H.We are taking two numbers 8523 + 7496 = 16019InputAddressData……50023501855029650374…… Flow Diagram Program OutputAddressData……600196016060201……

Copy Constructor vs Assignment Operator in C++

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

4K+ Views

The Copy constructor and the assignment operators are used to initializing one object to another object. The main difference between them is that the copy constructor creates a separate memory block for the new object. But the assignment operator does not make new memory space. It uses the reference variable to point to the previous memory block.Copy Constructor (Syntax)classname (const classname &obj) { // body of constructor }Assignment Operator (Syntax)classname Ob1, Ob2; Ob2 = Ob1;Let us see the detailed differences between Copy constructor and Assignment Operator.Copy ConstructorAssignment OperatorThe Copy constructor is basically an overloaded constructorAssignment operator is ... Read More

Update the ID of a MongoDB Document

Daniol Thomas
Updated on 30-Jul-2019 22:30:25

11K+ Views

You cannot update it but you can save a new id and remove the old id. Follow some steps in order to update the _id of a MongoDB. The steps are as follows:Step1: In the first step, you need to store ObjectId into a variable.anyVariableName=db.yourCollectionName.findOne({_id:yourObjectIdValue)});Step 2: In the second step, you need to set a new id.yourDeclaredVariableName._id=yourNewObjectIdValue;Step 3: In the third step, you need to insert new id on a document.db.yourCollectionName.insert(yourDeclaredVariableName);Step 4: In the fourth step, you need to remove the old id.db.yourCollectionName.remove({_id:yourOldObjectIdValue)});To understand the above steps, let us create a collection with document. The query to create a collection ... Read More

Maintain Session Between Web Client and Web Server

Arjun Thakur
Updated on 30-Jul-2019 22:30:25

2K+ Views

Following are the few options to maintain the session between the Web Client and the Web Server −CookiesA webserver can assign a unique session ID as a cookie to each web client and for subsequent requests from the client they can be recognized using the received cookie.This may not be an effective way as the browser at times does not support a cookie. It is not recommended to use this procedure to maintain the sessions.Hidden Form FieldsA web server can send a hidden HTML form field along with a unique session ID as follows −This entry means that, when the ... Read More

Set Decade Value in Java Tuples

Chandu yadav
Updated on 30-Jul-2019 22:30:25

145 Views

To set a new value in the Decade Tuple, you need to use the setAtX() method. Here, X is the index wherein you want to set the value. For example, setAt2() sets the value at index 2. The value to be included is to be set as the value in the parameter, likesetAt2(“Amit”);Let us first see what we need to work with JavaTuples. To work with Decade class in JavaTuples, you need to import the following packageimport org.javatuples.Decade;Note Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java ... Read More

Plotting Google Map Using Folium Package

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

1K+ Views

Folium is a very powerful python library which let you create seveal kind of Leaflet maps. As Leaflet/folium maps are interactive, so they are ideal for making dashborad building.InstallationInstalling folium is very easy using pip −$pip install foliumLike you can see from the below screenshot, you just need to type above command in your console/cmd and pip will install the folium as well as dependencies for your python installation.Basic Map#Import library import folium #Uses lat then lon. & zoomlevel 4.The bigger the zoom number, the closer in you get. mapOBJ = folium.Map(location=[17.3616, 78.4747], zoom_start = 4, tiles = 'Stamen ... Read More

LocalDateTime plusWeeks Method in Java

karthikeya Boyini
Updated on 30-Jul-2019 22:30:25

133 Views

An immutable copy of a LocalDateTime object where some weeks are added to it can be obtained using the plusWeeks() method in the LocalDateTime class in Java. This method requires a single parameter i.e. the number of weeks to be added and it returns the LocalDateTime object with the added weeks.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalDateTime ldt = LocalDateTime.now();       System.out.println("The current LocalDateTime is: " + ldt);       System.out.println("The LocalDateTime with 4 weeks added is: ... Read More

Find Out Number of Rows Affected by a DELETE in MySQL Command Line Tool

Samual Sam
Updated on 30-Jul-2019 22:30:25

750 Views

You can use row_count() at the end for this. Let us first create a table −mysql> create table rowAfftectedByDeleteDemo    -> (    -> CustomerId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> CustomerName varchar(20)    -> ); Query OK, 0 rows affected (0.86 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into rowAfftectedByDeleteDemo(CustomerName) values('John'); Query OK, 1 row affected (0.14 sec) mysql> insert into rowAfftectedByDeleteDemo(CustomerName) values('Carol'); Query OK, 1 row affected (0.10 sec) mysql> insert into rowAfftectedByDeleteDemo(CustomerName) values('Bob'); Query OK, 1 row affected (0.09 sec) mysql> insert into rowAfftectedByDeleteDemo(CustomerName) values('Sam'); Query ... Read More

Advertisements