Find Second Most Repeated String in a Sequence in Android

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

213 Views

This example demonstrate about How to find Second most repeated string in a sequence 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 code, we have taken a text view to show the second most sequence in an array.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.util.Log; import android.widget.TextView; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; ... Read More

Search for a Value in Java Octet Tuple

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

114 Views

To search for a value in Java Octet Tuple, you need to use the contains() method. The method returns a Boolean value stating whether the element set as a parameter exists in the values set in Octet Tuple or not. Let us first see what we need to work with JavaTuples. To work with Octet class in JavaTuples, you need to import the following package −import org.javatuples.Octet;Note − Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project -> Properties -> Java Build Path -> Add External Jars and upload the downloaded ... Read More

Include All Existing Fields and Add New Fields to Document in MongoDB

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

448 Views

You can achieve this with the help of $addFields operator. To understand the concept, let us create a collection with the document. The query to create a collection with a document is as follows −> db.addFieldDemo.insertOne({"EmployeeId":101, "EmployeeName":"Larry", "EmployeeDetails":{    "EmployeeSalary":65000, "EmployeeCity":"New York", "Message":"Hi"}}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c7f654d8d10a061296a3c44") }Display all documents from a collection with the help of find() method. The query is as follows −> db.addFieldDemo.find().pretty();The following is the output −{    "_id" : ObjectId("5c7f654d8d10a061296a3c44"),    "EmployeeId" : 101,    "EmployeeName" : "Larry",    "EmployeeDetails" : {       "EmployeeSalary" : 65000,     ... Read More

tmpfile Function in C

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

1K+ Views

The function tmpfile() creates a temporary file in binary update mode in C. It initializes in header file of a C program. It always returns a null pointer if the temporary file cannot be created. The temporary file deleted automatically just after the termination of program.SyntaxFILE *tmpfile(void)Return valueIf file creation is successful, the function returns a stream pointer to the temporary file created. If the file cannot be created, NULL pointer is returned.AlgorithmBegin.    Declare an array variable c[] to the character datatype and take a character data string.    Initialize a integer variable i ← 0.    Declare a ... Read More

Find Exact Array Match with Values in Different Order Using MongoDB

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

454 Views

To find exact array match with values in different order, you can use $all operator. Let us create a collection with documents. Following is the query>db.exactMatchArrayDemo.insertOne({"StudentName":"David", "StudentAge":22, "StudentGameScores":[45, 78, 98]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9c94702d6669774125246c") } >db.exactMatchArrayDemo.insertOne({"StudentName":"Chris", "StudentAge":23, "StudentGameScores":[45, 78]}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9c94a42d6669774125246d") }Following is the query to display all documents from a collection with the help of find() method> db.exactMatchArrayDemo.find().pretty();This will produce the following output{    "_id" : ObjectId("5c9c94702d6669774125246c"),    "StudentName" : "David",    "StudentAge" : 22,    "StudentGameScores" : [       45,       78, ... Read More

Get Minimum Value Using Comparator in Java

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

392 Views

First, declare an integer array and add some elements −Integer arr[] = { 40, 20, 30, 10, 90, 60, 700 };Now, convert the above array to List −List list = Arrays.asList(arr);Now, use Comparator and the reverseOrder() method. Using max() will eventually give you the maximum value, but with reverseOrder() it reverses the result −Comparator comp = Collections.reverseOrder(); System.out.println("Minimum element = "+Collections.max(list, comp));Example Live Demoimport java.util.Arrays; import java.util.Collections; import java.util.Comparator; import java.util.List; public class Demo {    @SuppressWarnings("unchecked")    public static void main(String args[]) {       Integer arr[] = { 40, 20, 30, 10, 90, 60, 700 };     ... Read More

mbtowc Function in C

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

103 Views

The C library function int mbtowc(whcar_t *pwc, const char *str, size_t n) converts a multibyte sequence to a wide character.Following is the declaration for mbtowc() function.int mbtowc(whcar_t *pwc, const char *str, size_t n)The parameters are −pwc − This is the pointer to an object of type wchar_t.str − This is the pointer to the first byte of a multi-byte character.str − This is the pointer to the first byte of a multi-byte character.n −This is the maximum number of bytes to be checked for character length.The return values are −If str is not NULL, the mbtowc() function returns the number ... Read More

Function Identifier in C

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

310 Views

Here we will see what is the __func__ C.Basically the __func__ or __FUNCTION__ (Some old versions of C and C+ + supports __func__). This macro is used to get the name of the current function.Example#include void TestFunction(){    printf("Output of __func__ is: %s", __func__ ); } main() {    printf("Output of __func__ is: %s", __func__ );    TestFunction(); }OutputOutput of __func__ is: main Output of __func__ is: TestFunction

Pin Diagram of 8086 Microprocessor

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

14K+ Views

The Intel 8086 is 40 pin DIP Microprocessor. Here we will see the actual pin level diagram of 8086 MPU.8086 was the first 16-bit microprocessor available in 40-pin DIP (Dual Inline Package) chip. Let us now discuss in detail the pin configuration of a 8086 Microprocessor.This is the actual pin diagram of 8086 Microprocessor.Now let us see the Pin functions of the 8086 microprocessor.PinsFunctionAD15 – AD0These are 16 address/data bus. AD0-AD7 carries low order byte data and AD8AD15 carries higher order byte data. During the first clock cycle, it carries 16-bit address and after that it carries 16-bit data.A16 – ... Read More

Search a Value in Java Tuples Quintet Class

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

111 Views

Use the contains() method to search a value in the Quintet class in JavaTuples.Let us first see what we need to work with JavaTuples. To work with Quintet class in JavaTuples, you need to import the following package −import org.javatuples.Quintet;Note − Steps to download and run JavaTuples program. If you are using Eclipse IDE to run Quintet Class in JavaTuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Quintet; public class Demo { public static void main(String[] args) { ... Read More

Advertisements