The min() method of the DoubleStream class returns an OptionalDouble describing the minimum element of this stream, or an empty OptionalDouble if this stream is empty.The syntax is as follows:OptionalDoublemin()Here, OptionalDouble is a container object which may or may not contain a double valueTo use the DoubleStream class in Java, import the following package:import java.util.stream.DoubleStream;Create a DoubleStream and add elements to the stream:DoubleStream doubleStream = DoubleStream.of(67.9, 89.9, 10.5, 95.8, 49.6);Get the maximum element from the DoubleStream:OptionalDouble res = doubleStream.max();The following is an example to implement DoubleStream min() method in Java:Example Live Demoimport java.util.OptionalDouble; import java.util.stream.DoubleStream; public class Demo { public ... Read More
In android, using vibrate service, we can vibrate android mobile. This example demonstrate about how to make an Android device vibrateStep 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 textview, when you click on textview. it will vibrate.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.content.Context; import android.content.Intent; import android.os.Build; import android.os.Bundle; import android.os.VibrationEffect; import android.os.Vibrator; import android.support.v7.app.AppCompatActivity; import android.view.View; import ... Read More
What is a Bitcoin?Bitcoin is an electronic payment system through a secure, verifiable and mathematical way. It is created by Satoshi Nakamoto in 2008 to produce a new means of exchange of money, independent of any centralization or central authority, which can be done electronically.Traditional currency is printed and distributed by the Government based on demand and supply in the market. Bitcoin is introduced as a peer-to-peer currency without any central authority or any government body to issue the Coins and track their transactions.What is MiningWhere do the Bitcoins come from when there is no central authority to create and ... Read More
Let’s say the following is our Integer array −Integer arr[] = { 50, 100, 150, 200, 250, 300 };Set the above integer array in HashSet −Setset = new HashSet(Arrays.asList(arr));Now, let us check whether the HashSet contains certain value or not −set.contains(150)TRUE is returned if the value is in the List, else FALSE is the return value.Example Live Demoimport java.util.Arrays; import java.util.HashSet; import java.util.Set; public class Demo { public static void main(String[] a) { Integer arr[] = { 50, 100, 150, 200, 250, 300 }; Setset = new HashSet(Arrays.asList(arr)); System.out.println(set.contains(200)); ... Read More
In C++ and Java, there is another kind of loop, called the foreach loop. This is basically a modification of for loop. This loop is used to access the data from some container. This can access the elements of some array quickly without performing initialization. This loop is used to do something for each element of a container, not doing things n times.Now let us see how the foreach loop is used in C++ and Java.Example#include using namespace std; int main() { int arr[] = { 11, 22, 33, 44, 55, 66, 77, 88, 99 }; for (int a : arr) //foreach loop cout
In the subtraction of two numbers, 8085 imposes the restriction that Accumulator will have one of the operands from which the other operand specified by one of the following will be subtracted.—Contents of an 8-bit register;—Contents of memory location pointed by HL pair;—Eight-bit immediate data.In 8085 Instruction, SUB is a mnemonic that stands for ‘SUBtract contents of R from Accumulator’. Here R stands for any of the following registers, or memory location M pointed by HL pair.R = A, B, C, D, E, H, L, or MMnemonics, Operand Opcode (in HEX)BytesSUB A971SUB B901SUB C911SUB D921SUB E931SUB H941SUB L951SUB M961In this instruction ... Read More
We write an 8085 assembly language program for the addition of 4 hex digits of a 16-bit number whose input is given from the keyboard and the result is displayed in the data field.FILE NAME ADDHEX.ASM ORG C000H CURDT: EQU FFF9H UPDDT: EQU 06D3H GTHEX: EQU 052FH HXDSP: EQU 05A1H OBUFF: EQU FFFAH MVI A, 0EH SIM EI ; Unmask RST5.5 and enable interrupts MVI B, 00 CALL GTHEX ; Input a 4 digit number and display in address field CALL HXDSP ; Store the 4 hex digits in 4 locations starting from OBUFF LXI H, OBUUF MOV A, M ... Read More
If you commit a database, it saves all the changes that have been done till that particular point.You can commit a database using the commit() method. Whenever any issue occurs you can revert the database to this point using the rollback() method. By default, some databases commit the databases automatically. But, while managing transactions you need to commit the database manually.In this scenario you can use the setAutoCommit() method. This method belongs to the Connection interface and, it accepts a boolean value.If you pass true to this method it turns on the auto-commit feature of the database and, if you ... Read More
This example demonstrates How to disable Bluetooth 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 text view to show Bluetooth status.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.bluetooth.BluetoothManager; import android.content.Context; import android.net.ConnectivityManager; import android.net.Network; import android.os.Build; import android.os.Bundle; import android.os.health.SystemHealthManager; import android.provider.Telephony; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.telephony.SmsManager; import android.view.View; import android.view.WindowManager; import android.widget.TextView; public class MainActivity ... Read More
The empty() method of the IntStream class returns an empty sequential IntStream.The syntax is as followsstatic IntStream empty()This is how you can create an empty IntStreamIntStream intStream = IntStream.empty();Now, using the count() method you can check the count of elements in the stream, which is 0 since we created an empty streamIntStream intStream = IntStream.empty();The following is an example to implement IntStream empty() method in JavaExample Live Demoimport java.util.stream.IntStream; public class Demo { public static void main(String[] args) { IntStream intStream = IntStream.empty(); System.out.println("The number of elements in the stream = "+intStream.count()); } ... Read More