The addAll() method of the AbstractCollection class in Java is used to add all of elements in the specified collection to this collection. It returns TRUE if the elements are successfully appendedThe syntax is as follows:public boolean addAll(Collection
Any number which can be expressed as a quotient or fraction in the form of p/q is called a rational number. The fractions module of Python library provides functionality for rational number arithmetic.This module defines a Fraction class. Its object can be constituted in various ways as below −Fraction(num, denom)The first version of Fraction constructor receives two parameters for numerator and denominator. Default numerator is 0 and default denominator is 1. Value of denominator = 0 throws ZeroDivisionError.>>> from fractions import Fraction >>> n1 = Fraction(2, 5) >>> n1 Fraction(2, 5) >>> n2 = Fraction(6, 15) >>> n2 Fraction(2, 5) ... Read More
To remove all collections whose name matches a string, you can follow some steps. Use for loop to iterate over all collections and find that particular collection name with certain string. After that, use the drop method to remove all collections.Let’s say we are using the database “sample”. The collections are as follows in sample database> show collections;This will produce the following outputarraySizeErrorDemo basicInformationDemo copyThisCollectionToSampleDatabaseDemo deleteAllRecordsDemo deleteDocuments deleteDocumentsDemo deleteMultipleIdsDemo deleteSomeInformation documentWithAParticularFieldValueDemo employee findListOfIdsDemo findMimimumElementInArrayDemo findSubstring getAllRecordsFromSourceCollectionDemo getElementWithMaxIdDemo insertDocumentWithDateDemo internalArraySizeDemo largestDocumentDemo makingStudentInformationClone oppositeAddToSetDemo prettyDemo returnOnlyUniqueValuesDemo selectWhereInDemo sourceCollection studentInformation sumOfValueDemo sumTwoFieldsDemo truncateDemo updateInformation userInformationNow remove all the collection names that match a ... Read More
To display 3 digits after decimal, use TRUNCATE(). Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, Value DECIMAL(10, 5) ); Query OK, 0 rows affected (0.51 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(Value) values(109.4567); Query OK, 1 row affected (0.25 sec) mysql> insert into DemoTable(Value) values(15.9875); Query OK, 1 row affected (0.28 sec) mysql> insert into DemoTable(Value) values(1234.2346789); Query OK, 1 row affected, 1 warning (0.14 sec)Following is the query to display all records from the table using select statement −mysql> select ... Read More
Let’s say we have the following string:String str = "YuBM787Nm";Now to display it as IntStream, use filter() and map() as shown below:int res = str.chars() .filter(Character::isDigit) .map(ch → Character.valueOf((char) ch)).sum();The following is an example to display string as IntStream:Examplepublic class Demo { public static void main(String[] args) { String str = "YuBM787Nm"; int res = str.chars() .filter(Character::isDigit) .map(ch -> Character.valueOf((char) ch)).sum(); System.out.println("String as IntStream = "+res); } }OutputString as IntStream = 166
These instructions are used to transfer/branch the instructions during an execution. There are two types of branching instructions. The unconditional branch and conditional branch.The Unconditional Program execution transfer instructions are as follows.OpcodeOperandDescriptionCALLaddressUsed to call a procedure and save their return address to the stack.RET----Used to return from the procedure to the main program.JMPaddressUsed to jump to the provided address to proceed to the next instruction.LOOPaddressUsed to loop a group of instructions until the condition satisfies, i.e., CX = 0 Now let us see the Conditional Program execution transfer instructions.OpcodeOperandDescriptionJCaddressUsed to jump if carry flag CY = 1JNCaddressUsed to jump if no ... Read More
Before getting into example, we should know what sqlite data base in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrate about How to filter data using where Clause and “GLOB” in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill ... Read More
You can use $where operator along with find() method to compare two fields in MongoDB. The syntax is as follows:db.yourCollectionName.find({$where:”yourCondition”}).pretty();To understand the above syntax, let us create a collection with some documents. The query to create a collection with documents is as follows:>db.compareTwoFields.insert({"Id":1, "FullName":{"FirstName":"John", "LastName":"Smith"}, "BranchName":"ComputerScience"}); WriteResult({ "nInserted" : 1 }) >db.compareTwoFields.insert({"Id":2, "FullName":{"FirstName":"Smith", "LastName":"Smith"}, "BranchName":"Civil"}); WriteResult({ "nInserted" : 1 }) >db.compareTwoFields.insert({"Id":3, "FullName":{"FirstName":"David", "LastName":"Smith"}, "BranchName":"Mechanical"}); WriteResult({ "nInserted" : 1 })Now you can display all documents from a collection with the help of find() method. The query is as follows:> db.compareTwoFields.find().pretty();The following is the output:{ "_id" : ObjectId("5c6c237568174aae23f5ef64"), ... Read More
The useBean action is quite versatile. It first searches for an existing object utilizing the id and scope variables. If an object is not found, it then tries to create the specified object.The simplest way to load a bean is as follows −Once a bean class is loaded, you can use jsp:setProperty and jsp:getProperty actions to modify and retrieve the bean properties.Following table lists out the attributes associated with the useBean action −S.No.Attribute & Description1classDesignates the full package name of the bean.2typeSpecifies the type of the variable that will refer to the object.3beanNameGives the name of the bean as specified ... Read More
The tag is used to copy a time zone object into the specified scoped variable.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaultValueTime zone to expose as a scoped or configuration variableYesNonevarName of the variable to store the new time zoneNoReplace defaultscopeScope of the variable to store the new time zoneNoPageExample JSTL fmt:setTimeZone Tag Date in Current Zone: Change Time Zone to GMT-8 Date in Changed Zone: The above code will generate the following result −Date in Current Zone: 23 September 2010 15:21:37 GST Change Time Zone to GMT-8 Date in Changed Zone: 23 September 2010 03:21:37 GMT-08:00