It can be checked if a particular LocalTime is before the other LocalTime in a timeline using the isBefore() method in the LocalTime class in Java. This method requires a single parameter i.e. the LocalTime object that is to be compared. It returns true if the LocalTime object is before the other LocalTime object and false otherwise.A program that demonstrates this is given as followsExample Live Demoimport java.time.*; public class Main { public static void main(String[] args) { LocalTime lt1 = LocalTime.parse("11:37:12"); LocalTime lt2 = LocalTime.parse("23:15:30"); System.out.println("The LocalTime lt1 is: " ... Read More
An immutable copy of the Period object where some years are subtracted from it can be obtained using the minusYears() method in the Period class in Java. This method requires a single parameter i.e. the number of years to be subtracted and it returns the Period object with the subtracted years.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo { public static void main(String[] args) { String period = "P5Y7M15D"; Period p1 = Period.parse(period); System.out.println("The Period is: " + p1); Period p2 ... Read More
Synchronous optical networking (SONET) is a physical layer protocol for transmitting multiple digital bit streams over optical fiber links that form the backbone of the communication networks. Packet-over-SONET (POS) is a standard that maps IP packets into SONET frames. To implement this mechanism, Point – to – Point Protocol (PPP) runs on IP routers. Point – to – Point Protocol (PPP) is a data link layer protocol that is used to transmit data between two directly connected (point-to-point) computers. It is a byte-oriented protocol that is widely used in broadband communications having heavy loads and high speeds.The following diagram shows ... Read More
The syntax is as follows to perform UPDATE using IF condition in MySQL −update yourTableName set yourColumnName =if(yourColumnName =yourOldValue, yourNewValue, yourColumnName);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table updateIfConditionDemo -> ( -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> UserName varchar(20), -> UserAge int -> ); Query OK, 0 rows affected (4 min 0.59 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into updateIfConditionDemo(UserName, UserAge) values('Larry', 23); Query OK, ... Read More
Initialization vector can be done in many ways1) Initialize a vector by push_back() methodAlgorithmBegin Declare v of vector type. Call push_back() function to insert values into vector v. Print “Vector elements:”. for (int a : v) print all the elements of variable a. End.Example Live Demo#include #include using namespace std; int main() { vector v; v.push_back(6); v.push_back(7); v.push_back(10); v.push_back(12); cout
In order to terminate a MongoDB shell script earlier, you need to use quit. Following is the syntaxquit() quit(1)Let us create a script and try to write quit() or quit(1) in shell. At first, we will create the following collection with documents> db.flightInformation.insertOne({"FlightName":"Flight-1", "ArrivalTime":new ISODate("2019-03-12")}); { "acknowledged" : true, "insertedId" : ObjectId("5ca1e341e941bbb0e8bf5639") } > db.flightInformation.insertOne({"FlightName":"Flight-2", "ArrivalTime":new ISODate("2019-03-31")}); { "acknowledged" : true, "insertedId" : ObjectId("5ca1e351e941bbb0e8bf563a") }Following is the query to display all documents from a collection with the help of find() method> db.flightInformation.find().pretty();This will produce the following output{ "_id" : ObjectId("5ca1e341e941bbb0e8bf5639"), "FlightName" : "Flight-1", ... Read More
Let us first create a List in Java −Listlist = new ArrayList(); list.add("A"); list.add("B"); list.add("C");Now to convert the above list to read-only, use Collections −list = Collections.unmodifiableList(list);We have converted the above list to read-only. Now, if you will try to add more elements to the list, then the following error would be visible −Exception in thread "main" java.lang.Error: Unresolved compilation problem:Example Live Demoimport java.util.ArrayList; import java.util.Collections; import java.util.List; public class Demo { public static void main(String args[]) throws Exception { Listlist = new ArrayList(); list.add("A"); list.add("B"); list.add("C"); ... Read More
Use DATE_FORMAT() and set the specifiers to display only the MonthName and Year. Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, AdmissionDate date ); Query OK, 0 rows affected (0.69 sec)Insert records in the table using insert command −mysql> insert into DemoTable(AdmissionDate) values('2013-04-21'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable(AdmissionDate) values('2014-01-31'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(AdmissionDate) values('2016-09-01'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable(AdmissionDate) values('2018-12-12'); Query OK, 1 row affected (0.11 sec) mysql> insert ... Read More
A custom ArrayList can have multiple types of data and its attributes in general are based on the user requirements.A program that demonstrates a custom ArrayList is given as follows −Example Live Demoimport java.util.ArrayList; public class CustomArrayList { int n = 5; class Employee { int eno; String name; Employee(int eno, String name) { this.eno = eno; this.name = name; } } public static void main(String args[]) { int eno[] = {101, 102, 103, ... Read More
In this program we will see how to add two 8-bit numbers which are in different segments.Problem StatementWrite 8086 Assembly language program to add content of memory location 2000:500 and 3000:600, and store the final result at 5000:700.DiscussionHere we are initializing the CX register with the base address of first operand. Also store this into data segment register. Now take the number from offset 500 to AX. Now point CX to 3000, and load DS with 3000. Then add the AX with data at position 3000:0600, and store result at AX. Now again load CX as 5000, and store the ... Read More