Block Chain is the most important component of any cryptocurrency network. Cryptocurrency is based on distributed, transparent public ledger where all the transactions ever made on a cryptocurrency are noted in the blocks and added to the block chain. Miners get attractive rewards to verify and create a new block and add it successfully to the Block Chain.Here comes the twist. There will be some blocks which are created, but not accepted by the block chain network. There are called Orphan Blocks. Orphan blocks are verified and valid blocks, but not accepted by the block chain network due to a ... Read More
This example demonstrate about How to get android notifications when the app was closedStep 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. Step 3 − Add the following code to src/MainActivitypackage app.tutorialspoint.com.notifyme ; import android.content.Intent ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; public class MainActivity extends AppCompatActivity { @Override protected void onCreate (Bundle savedInstanceState) { super .onCreate(savedInstanceState) ; setContentView(R.layout. activity_main ) ... Read More
Yes, it is mandatory to implement all the methods in a class that implements an interface until and unless that class is declared as an abstract class.There are only two choices −Implement every method defined by the interface.Declare the class as an abstract class, as a result, forces you to subclass the class (and implement the missing methods) before you can create any objects.The only case the class do not need to implement all methods in the interface is when any class in its inheritance tree has already provided concrete (i.e. non-abstract) method implementations then the subclass is under no ... Read More
At first, let us create a horizontal slider −JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 55);Now, we will set it to move right-to-left using setInverted() −slider.setInverted(true);The following is an example to move the horizontal slider right-to-left −Examplepackage my; import java.awt.Color; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JSlider; import javax.swing.WindowConstants; public class SwingDemo { public static void main(String[] args) { JFrame frame = new JFrame("Frame with Slider"); JSlider slider = new JSlider(JSlider.HORIZONTAL, 0, 100, 55); slider.setInverted(true); slider.setMinorTickSpacing(10); slider.setMajorTickSpacing(25); slider.setPaintTicks(true); ... Read More
Let us first create a collection with documents −> db.upperCaseFiveLetterDemo.insertOne({"StudentFullName":"JOHN Smith"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd7edef1a844af18acdffb2") } > db.upperCaseFiveLetterDemo.insertOne({"StudentFullName":"SAM Williams"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd7ee011a844af18acdffb3") } > db.upperCaseFiveLetterDemo.insertOne({"StudentFullName":"CAROL Taylor"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd7ee101a844af18acdffb4") } > db.upperCaseFiveLetterDemo.insertOne({"StudentFullName":"Bob Taylor"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd7ee351a844af18acdffb5") } > db.upperCaseFiveLetterDemo.insertOne({"StudentFullName":"DAVID Miller"}); { "acknowledged" : true, "insertedId" : ObjectId("5cd7ee451a844af18acdffb6") }Following is the query to display all documents from a collection with the help of find() method −> db.upperCaseFiveLetterDemo.find().pretty();This will produce the following output −{ "_id" : ... Read More
This is a famous puzzle problem. Suppose there is a building with n floors, if we have m eggs, then how can we find the minimum number of drops needed to find a floor from which it is safe to drop an egg without breaking it.There some important points to remember −When an egg does not break from a given floor, then it will not break for any lower floor also.If an egg breaks from a given floor, then it will break for all upper floors.When an egg breaks, it must be discarded, otherwise we can use it again.Input - The ... Read More
Cryptocurrency is entirely dependent on Block Chains to maintain their transactions. A block is like a page of a ledger book where some transactions are written in ink, permanent which cannot be altered. A block typically consists of transactions of bitcoin or any other cryptocurrency and the details of transactions - who has sent, who has received, timestamp and previous blocks information to link it to the Block chain. This information is passed through a hashing algorithm like SHA 256 and creates a 32-bit hash value. This hash value is irreversible.Thus a block is a permanent store of records, which ... Read More
This example demonstrate about How to Send a notification when the Android app is closedStep 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. Step 3 − Add the following code to src/MainActivitypackage app.tutorialspoint.com.notifyme ; import android.content.Intent ; import android.os.Bundle ; import android.support.v7.app.AppCompatActivity ; import android.view.View ; public class MainActivity extends AppCompatActivity { @Override protected void onCreate (Bundle savedInstanceState) { super .onCreate(savedInstanceState) ; setContentView(R.layout. activity_main ... Read More
Use $set operator along with update() for this. Let us first create a collection with documents. Here we have set one field as NumberLong −> db.findAndReplaceDemo.insertOne({"UserId":NumberLong(101)}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2c960b64f4b851c3a13b6") } > db.findAndReplaceDemo.insertOne({"UserId":NumberLong(110)}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2c966b64f4b851c3a13b7") } > db.findAndReplaceDemo.insertOne({"UserId":NumberLong(101)}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2c969b64f4b851c3a13b8") } > db.findAndReplaceDemo.insertOne({"UserId":NumberLong(120)}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2c96cb64f4b851c3a13b9") } > db.findAndReplaceDemo.insertOne({"UserId":NumberLong(130)}); { "acknowledged" : true, "insertedId" : ObjectId("5cd2c96eb64f4b851c3a13ba") }Following is the query to display all documents from a collection with the help of find() method ... Read More
To set the text of the label component to be right-justified and bottom-aligned, you need to set the alignment. Set the label to be on the right and bottom aligned −JLabel label = new JLabel("Total Runs", JLabel.RIGHT); label.setVerticalAlignment(JLabel.BOTTOM);Here, we have set the size of the label as well as the color that includes foreground and background color −label.setPreferredSize(new Dimension(220, 70)); label.setOpaque(true); label.setBackground(Color.YELLOW); label.setForeground(Color.RED);The following is an example to set the content of the lable to be right-justified and bottom-aligned −Examplepackage my; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.Font; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JTextArea; import javax.swing.WindowConstants; public class SwingDemo ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP