ConcurrentSkipListSet in Java

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

304 Views

The ConcurrentSkipListSet has elements that are sorted by default. Also, its implementation is based on the ConcurrentSkipListMap. The ConcurrentSkipListSet class also implements the Collection interface as well as the AbstractSet class. It is a part of the Java Collection Framework.A program that demonstrates this is given as follows −Example Live Demoimport java.util.concurrent.ConcurrentSkipListSet; public class Demo {    public static void main(String[] args) {       ConcurrentSkipListSet csls = new ConcurrentSkipListSet();       csls.add(7);       csls.add(4);       csls.add(1);       csls.add(9);       csls.add(3);       System.out.println("The elements in ConcurrentSkipListSet are: " + ... Read More

Java Signature getProvider Method

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

214 Views

The provider for the signature object can be obtained using the method getProvider() in the class java.security.Signature. This method requires no parameters and it returns the provider for the signature object.A program that demonstrates this is given as follows −Example Live Demoimport java.security.*; import java.util.*; public class Demo {    public static void main(String[] argv) {       try {          Signature signature = Signature.getInstance("SHA256withRSA");          Provider provider = signature.getProvider();          System.out.println("The Provider is: " + provider);       } catch (NoSuchAlgorithmException e) { ... Read More

Generate and Parse MAC OS X PLIST Files Using Python plistlib

Smita Kapse
Updated on 30-Jul-2019 22:30:25

2K+ Views

Files with '.plist' the extension is used by Mac OS X applications to store application properties. The plislib module provides an interface to read/write operations of these property list files.The plist file format serializes basic object types, like dictionaries, lists, numbers, and strings. Usually, the top level object is a dictionary. To write out and to parse a plist file, use the dump() and load() functions. Serialized byte strings are handled by use dumps() and loads() functions. Values can be strings, integers, floats, booleans, tuples, lists, dictionaries (but only with string keys).This module defines the following functions −load()Read a plist ... Read More

What is a Buffer Attribute in JSP

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

1K+ Views

The buffer attribute specifies the buffering characteristics for the server output response object.You may code a value of "none" to specify no buffering so that the servlet output is immediately directed to the response object or you may code a maximum buffer size in kilobytes, which directs the servlet to write to the buffer before writing to the response object.To direct the servlet to write the output directly to the response output object, use the following −Use the following to direct the servlet to write the output to a buffer of size not less than 8 kilobytes −

ArrayBlockingQueue drainTo Method in Java

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

252 Views

The drainTo() method of the ArrayBlockingQueue class removes all available elements from this queue and adds them to the given collection. It returns the number of elements transferred.The syntax is as followsint drainTo(Collection

Group By the Number of Rows Returned by Group By in MySQL

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

218 Views

You can use GROUP_CONCAT() for this. To understand the above concept, let us create a table.The query to create a table is as followsmysql> create table groupByDemo    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> Name varchar(100)    -> ); Query OK, 0 rows affected (1.31 sec)Insert some records in the table using insert command.The query is as followsmysql> insert into groupByDemo(Name) values('John'); Query OK, 1 row affected (0.19 sec) mysql> insert into groupByDemo(Name) values('Carol'); Query OK, 1 row affected (0.14 sec) mysql> insert into groupByDemo(Name) values('Carol'); Query OK, 1 row affected (0.10 sec) ... Read More

Query MongoDB for Entries with Specific Value in Array Field

Anvi Jain
Updated on 30-Jul-2019 22:30:25

93 Views

Yes, to query for a field in an object in the array with MongoDB, use the following syntax −db.yourCollectionName.find({"yourOuterFieldName": { $elemMatch: { "yourInnerFieldName": "yourValue" } } } ).pretty();To understand the above concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.objectInAnArrayDemo.insertOne({ "StudentDetails": [{    "StudentName": "John", "StudentMessage": "Hi"}, {"StudentName": "Larry", "StudentMessage": "Hello"}]}) {    "acknowledged" : true,    "insertedId" : ObjectId("5c92635d36de59bd9de06381") } > db.objectInAnArrayDemo.insertOne({ "StudentDetails": [{    "StudentName": "Carol", "StudentMessage": "Hello"}, {"StudentName": "David", "StudentMessage": "Good Morning"}]}) {    "acknowledged" : true,    "insertedId" : ObjectId("5c92637936de59bd9de06382") }Display all documents ... Read More

Query an Array for a Regular Expression Match

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

209 Views

To query an array string for a regexp match, use the following syntaxdb.yourCollectionName.find( { yourFieldName: /yourStartingValue./ } ).pretty();Let us first create a collection with documents> db.queryArrayDemo.insertOne({"StudentFullName":["Carol Taylor", "Caroline Williams", "Claire Brown"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca2774c6304881c5ce84ba0") } > db.queryArrayDemo.insertOne({"StudentFullName":["John Smith", "Jace Doe", "Jabin Brown"]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5ca277b36304881c5ce84ba1") }Following is the query to display all documents from a collection with the help of find() method> db.queryArrayDemo.find().pretty();This will produce the following output{    "_id" : ObjectId("5ca2774c6304881c5ce84ba0"),    "StudentFullName" : [       "Carol Taylor",       "Caroline Williams",     ... Read More

CopyOnWriteArraySet in Java

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

117 Views

A thread safe version of the set is the CopyOnWriteArraySet in Java. This set uses an CopyOnWriteArrayList internally for the set operations. The CopyOnWriteArraySet was introduced by the JDK 1.5.A program that demonstrates this is given as follows −Example Live Demoimport java.util.concurrent.*; public class Demo extends Thread {    public static void main(String[] args) {       CopyOnWriteArraySet cowArraySet = new CopyOnWriteArraySet();       cowArraySet.add("Amy");       cowArraySet.add("John");       cowArraySet.add("Bob");       cowArraySet.add("Clara");       cowArraySet.add("Peter");       System.out.println(cowArraySet);    } }The output of the above program is as follows −Output[Amy, John, Bob, ... Read More

8086 Program to Find Average of N Numbers

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

7K+ Views

In this program we will see how to find the average of n numbers in a given series.Problem StatementWrite 8086 Assembly language program to find the average of n numbers stored in a given series starts from memory offset 501. The size of the series is stored at memory offset 500.DiscussionTo do this task we are initializing the Source Index (SI) register to the starting address of the series. We are also taking the series size into CL. The CL will be used as counter. To store add we are using AL register. Initially set AL to 0. In each ... Read More

Advertisements