This is a simple C++ program of an uncommon representation of array elements.#include using namespace std; int main() { int array[5] = {7,7,7, 6, 6}; for (int i = 0; i < 5; i++) cout
To add elements to the ArrayBlockingQueue class, use the add() method.The syntax is as follows:boolean add(E ele)Here, ele is the element to be added to the queue.To work with ArrayBlockingQueue class, you need to import the following package:import java.util.concurrent.ArrayBlockingQueue;The following is an example to add elements in Java ArrayBlockingQueue class:Example Live Demoimport java.util.concurrent.ArrayBlockingQueue; public class Demo { public static void main(String[] args) { ArrayBlockingQueue q = new ArrayBlockingQueue(7); q.add(100); q.add(250); q.add(300); q.add(450); q.add(550); q.add(600); q.add(700); ... Read More
Before getting into an example, we should know what arrayblockingqueue is, it travels FIFO manner and the first element going to live the longest period of time and last element of the queue going to live a short period of the time.This example demonstrates about How to use pool() ArrayBlockingQueue 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 a text view to show ... Read More
Bitcoin wallets come on different platforms with different features. There is not “one size fits all” concept.Bitcoin wallet can be set up electronically either on your mobile or desktop. It is an application or a program which allows you to send or receive Bitcoin cash, and keep track of your transactions and history. The software program stores the private and public keys and interacts with various block chains to enable the users to send and receive digital currency and also monitor their balance. If you want to store and use the crypto currency you need a Digital Wallet.They are downloaded ... Read More
Read-only Hashtable would mean users won’t be able to add or remove elements from it. Let us first create a Hashtable with key-value pair −Hashtablehash = new Hashtable(); hash.put("1", "A"); hash.put("2", "B"); hash.put("3", "C"); hash.put("4", "D"); hash.put("5", "E"); hash.put("6", "F"); hash.put("7", "G");Now, use unmodifiableMap() to form a Hashtable read-only −Mapm = Collections.unmodifiableMap(hash);Example Live Demoimport java.util.Collections; import java.util.Hashtable; import java.util.Map; public class Demo { public static void main(String[] s) { Hashtablehash = new Hashtable(); hash.put("1", "A"); hash.put("2", "B"); hash.put("3", "C"); hash.put("4", "D"); hash.put("5", ... Read More
Here we will see what is the difftime() function in C. The difftime() is used to get the differences between two time values.difftime() takes two time argument, the first one is the lower bound, and the second one is the upper bound. And it returns the differences between these two arguments.Example#include #include #include main() { int sec; time_t time1, time2; time(&time1); printf("Current Time: %ld",time1); for (sec = 1; sec
We interface the I/O device in a very segmented manner and is carried systematically. In the interfacing of seven segment display to 8085 microcontroller it is found that An output device which is very common is, especially in the kit of 8085 microprocessor and it is the Light Emitting Diode consisting of seven segments. Moreover, we have eight segments in a LED display consisting of 7 segments which includes ‘.’, consisting of character 8 and having a decimal point just next to it. We denote the segments as ‘a, b, c, d, e, f, g, and dp’ where dp signifies ... Read More
To get total in the last row of MySQL result, use the following syntax −( SELECT yourColumnName1, yourColumnName2, yourColumnName3, . . N FROM yourTableName ) UNION ( SELECT "yourMessage" AS anyAliasName1, SUM(yourColumnName1) AS anyAliasName2, SUM(yourColumnName2) AS anyAliasName3, . . N FROM yourTableName );To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table ProductDemo -> ( -> ProductId varchar(10), -> ProductQuantity int, -> ProductValue int -> ); Query OK, 0 ... Read More
There are two types of result sets namely, forward only and, bidirectional.Forward only ResultSet: The ResultSet object whose cursor moves only in one direction is known as forward only ResultSet. By default, JDBC result sets are forward-only result sets.You can move the cursor of the forward only ResultSets using the next() method of the ResultSet interface. It moves the pointer to the next row from the current position. This method returns a boolean value. If there are no rows next to its current position it returns false, else it returns true.Therefore, using this method in the while loop you can ... Read More
This example demonstrate about How to check android mobile supports STEP COUNTER sensorStep 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 STEP COUNTER sensor information.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.SuppressLint; import android.content.Context; import android.hardware.Sensor; import android.hardware.SensorManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; public class MainActivity extends AppCompatActivity { ... Read More