Ankith Reddy has Published 996 Articles

The listIterator() method of Java AbstractSequentialList class

Ankith Reddy

Ankith Reddy

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

103 Views

The listIterator() method of the AbstractSequentialList class returns a list iterator over the elements in this list.The syntax is as followspublic abstract ListIterator listIterator(int index)Here, index is the index of the first element to be returned from the list iterator. The ListIterator here is the iterator for lists.To work with ... Read More

Get distinct values and count them in MySQL

Ankith Reddy

Ankith Reddy

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

501 Views

To get distinct values and count them, you can use GROUP BY clause.The syntax is as followsselect yourColumnName, count(*) as anyAliasName from yourTableName group by yourColumnName;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table GroupByAndCountDemo    -> ( ... Read More

Inserting Date() in MongoDB through Mongo shell?

Ankith Reddy

Ankith Reddy

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

1K+ Views

In order to insert Date() in MongoDB through Mongo shell, use the following syntaxvar yourVariableName= new Date(year, month, day, hour, minute); db.yourCollectionName({yourDateFieldName:yourVariableName});Let us first create a date variable> var creatingDate = new Date(2019, 03, 29, 13, 12);Let us create a collection with documents:>db.insertingDateUsingVariableDemo.insertOne({"UserName":"John", "UserMessages":["Hi", "Hello", "Awesome"], "UserPostDate":creatingDate});Following is the query ... Read More

The contains() method of AbstractSequentialList in Java

Ankith Reddy

Ankith Reddy

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

131 Views

The contains() method of AbstractSequentialList in Java is used to check whether an element is in the Collection.The syntax is as followspublic boolean contains(Object ob)Here, ob is the element to be checked. To work with the AbstractSequentialList class in Java, you need to import the following packageimport java.util.AbstractSequentialList;The following is ... Read More

Can I retrieve multiple documents from MongoDB by id?

Ankith Reddy

Ankith Reddy

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

2K+ Views

Yes, to retrieve multiple docs from MongoDB by id, use the $in operator. The syntax is as followsdb.yourCollectionName.find({_id:{$in:[yourValue1, yourValue2, yourValue3, ...N]}});Let us first create a collection with documents:> db.retrieveMultipleDocsByIdDemo.insertOne({"_id":10, "CustomerName":"John"}); { "acknowledged" : true, "insertedId" : 10 } > db.retrieveMultipleDocsByIdDemo.insertOne({"_id":14, "CustomerName":"Chris"}); { "acknowledged" : true, "insertedId" : 14 } > ... Read More

What is a request object in JSP?

Ankith Reddy

Ankith Reddy

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

1K+ Views

The request object is an instance of a javax.servlet.http.HttpServletRequest object. Each time a client requests a page, the JSP engine creates a new object to represent that request.The request object provides methods to get HTTP header information including form data, cookies, HTTP methods, etc.Following is the example which uses getHeaderNames() ... Read More

How to convert HASHMAP to JSON using GSON in Android?

Ankith Reddy

Ankith Reddy

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

1K+ Views

GSON is java library, It is used to convert OBJECT to JSON and JSON to Object. Internally it going to work based on serialization and deserialization.This example demonstrates how to convert HASHAMP to JSON using GSON library.Step 1 − Create a new project in Android Studio, go to File ⇒ ... Read More

How to hide action bar in android?

Ankith Reddy

Ankith Reddy

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

893 Views

This example demonstrate about How to hide action bar 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 ... Read More

DoubleStream filter() method in Java

Ankith Reddy

Ankith Reddy

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

126 Views

The filter() method of the DoubleStream class returns a stream consisting of the elements of this stream that match the given predicate.The syntax is as followsDoubleStream filter(DoublePredicate predicate)The parameter predicate is a stateless predicate to apply to each element to determine if it should be included.To use the DoubleStream class ... Read More

LongStream concat() method in Java

Ankith Reddy

Ankith Reddy

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

102 Views

The concat() method in the LongStream class creates a concatenated stream whose elements are all the elements of the first stream followed by all the elements of the second stream.The syntax is as follows.static LongStream concat(LongStream one, LongStream two)Here, parameter one is the 1st stream, whereas two is the 2nd ... Read More

Advertisements