LongStream findAny Method in Java

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

119 Views

The findAny() method of the LongStream class in Java returns an OptionalLong describing some element of the stream, or an empty OptionalLong if the stream is empty.The syntax is as follows:OptionalLong findAny()Here, OptionalLong is a container object which may or may not contain a long value.To use the LongStream class in Java, import the following package:import java.util.stream.LongStream;The following is an example to implement LongStream findAny() method. The isPresent() method of the OptionalLong class returns true if the value is present:Exampleimport java.util.OptionalLong; import java.util.stream.LongStream; public class Demo {    public static void main(String[] args) {       LongStream longStream = ... Read More

Use Poll in Android PriorityBlockingQueue

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

157 Views

Before getting into the example, we should know what PriorityBlockingQueue is. It is an unbounded queue and follows the same order as a priority queue. The main usage of priority blocking queue is, it going to handle out of memory error.This example demonstrates about How to use poll() in android PriorityBlockingQueueStep 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 PriorityBlockingQueue ... Read More

The 51 Attack

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

242 Views

The 51% attack refers to an attack on the block chain network, deceiving the miners with a duplicate block chain which has more than 50% acceptance and spending the same bitcoins again.To put it in simple words, a single miner or a pool of miners controlling more than 50 (say 51%) of the cryptocurrency network’s mining hash power, can attack the block chain network and reverse the transactions. Once they have more than 50% of hashing power they can take control of the cryptocurrency network and they could double spend the coins.However, by controlling the majority of computing power on ... Read More

Lock Screen Orientation Programmatically in iOS

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

2K+ Views

You might come across a scenario where you need to show the UI in a specific orientation may be Landscape or Portrait.We will be seeing how to lock orientation programmatically using Swift in iOS.Open Xcode → New Project → ViewController.swift write the below code.// Set the shouldAutorotate to False override open var shouldAutorotate: Bool {    return false } // Specify the orientation. override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {    return .portrait }

Subtract by 1 if Field Value is 0 in MySQL

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

327 Views

You can use CASE statement with UPDATE command for this. Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    Value int ); Query OK, 0 rows affected (1.44 sec)Insert records in the table using insert command −mysql> insert into DemoTable(Value) values(100); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable(Value) values(0); Query OK, 1 row affected (4.16 sec) mysql> insert into DemoTable(Value) values(104); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable(Value) values(0); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable(Value) values(5); Query ... Read More

Working of 74138 Decoder IC

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

8K+ Views

Let’s take an Integrated Circuit decoder. We take the popular 3 to 8 decoder Integrated Circuit 74138. The Integrated Circuit is of 16 pins.We have three input pins which are actively in high state and are classified as I2, I1 and I0. The outputs are actively in low state and are eight in number and are classified as O7*, O6*, …, O0*. A power supply of +5 V DC is needed by the chip and is Grounded.                                                ... Read More

Operational Modes of 8255

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

2K+ Views

There are three modes of operation which are supported by 8255. We call them as mode 0, mode1 and mode 2.We call the mode 0 as the simple Input Output or the basic Input Output for performing the simplest mode of operation. Every ports of 8255 can be programmed to work in mode 0.We call mode 1 as the strobed Input Output or handshake Input Output. It is useful when data is supplied to the input device by the microprocessor at irregular interval of time. Finally, when the data is read by the processor the port informs the Input device ... Read More

Find Highest Value in Android SQLite

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

464 Views

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 find highest value in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to ... Read More

Remove Data from HashMap to ArrayList for ListView in Android

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

215 Views

This example demonstrate about How to remove data from hashmap to arraylist for listview in AndroidStep 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 the name and record number as Edit text, when user click on save button it will store the data ... Read More

Get Current Country Name from Network Provider in Android

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

217 Views

This example demonstrate about How to get current country name from Network provider 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 current country name.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.Manifest; import android.content.pm.PackageManager; import android.location.Address; import android.location.Geocoder; import android.location.Location; import android.location.LocationManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v4.app.ActivityCompat; import android.support.v7.app.AppCompatActivity; import ... Read More

Advertisements