Correctly Implement END IF Statement in MySQL Stored Procedure

Ankith Reddy
Updated on 30-Jul-2019 22:30:25

265 Views

The following is the syntax of END IF statement in MySQLIF yourCondition THEN yourStatement ELSE yourStatement END IFHere is the demo of END IF statement while creating a stored proceduremysql> DELIMITER // mysql> CREATE PROCEDURE Sp_Test( IN value INT ) - > BEGIN - > IF value < 10 THEN - > select 'Your value is less than 10'; - > ELSE - > select 'Your value is greater than 10'; - > END IF; ... Read More

LocalDateTime compareTo Method in Java

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

357 Views

Two LocalDateTime objects can be compared using the compareTo() method in the LocalDateTime class in Java. This method requires a single parameter i.e. the LocalDateTime object to be compared.If the first LocalDateTime object is greater than the second LocalDateTime object it returns a positive number, if the first LocalDateTime object is lesser than the second LocalDateTime object it returns a negative number and if both the LocalDateTime objects are equal it returns zero.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main {    public static void main(String[] args) {       LocalDateTime ldt1 ... Read More

DoubleStream Builder Add Method in Java

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

123 Views

The add() method of the DoubleStream.Builder class in Java adds an element to the stream being built. The method returns this builder.The syntax is as followsdefault DoubleStream.Builder add(double ele)Here, ele is the element to be added to this stream.To use the DoubleStream.Builder class in Java, import the following packageimport java.util.stream.DoubleStream; Create DoubleStream.Builder: DoubleStream.Builder builder = DoubleStream.builder(); Now add some elements: builder.add(23.5); builder.add(33.1); builder.add(35.6); builder.add(53.1);The following is an example to implement DoubleStream.Builder add() method in JavaExample Live Demoimport java.util.stream.DoubleStream; public class Demo {    public static void main(String[] args) {       DoubleStream.Builder builder = DoubleStream.builder();       builder.add(23.5);   ... Read More

Use Size in Android ConcurrentLinkedQueue

Vrundesha Joshi
Updated on 30-Jul-2019 22:30:25

105 Views

Before getting into the example, we should know what ConcurrentLinkedQueue is, it is an unbounded queue based on linked nodes. Multiple threads can access queue elements with safety. Elements travel based on queue strategy as FIFO and elements going to insert from a tail. It does not allow null values.This example demonstrates about How to use size() in android ConcurrentLinkedQueueStep 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, ... Read More

Reorder Integer Except for Value 0 with MySQL

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

105 Views

To reorder integer except for value 0, use the below syntax −select *from yourTableName order by yourColumnName=0 ,yourColumnName;Let us first create a table −mysql> create table reorderIntegerExcept0    -> (    -> value int    -> ); Query OK, 0 rows affected (0.70 sec)Following is the query to insert records in the table using insert command −mysql> insert into reorderIntegerExcept0 values(90); Query OK, 1 row affected (0.17 sec) mysql> insert into reorderIntegerExcept0 values(10); Query OK, 1 row affected (0.21 sec) mysql> insert into reorderIntegerExcept0 values(0); Query OK, 1 row affected (0.18 sec) mysql> insert into reorderIntegerExcept0 values(40); ... Read More

Generate Different Random Numbers in a Loop in C++

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

4K+ Views

Let us see how to generate different random numbers using C++. Here we are generating random numbers in range 0 to some value. (In this program the max value is 100).To perform this operation we are using the srand() function. This is in the C++ library. The function void srand(unsigned int seed) seeds the random number generator used by the function rand.The declaration of srand() is like below −void srand(unsigned int seed)It takes a parameter called seed. This is an integer value to be used as seed by the pseudo-random number generator algorithm. This function returns nothing.To get the number ... Read More

Virtual Functions Implementation in C++

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

723 Views

Virtual functions in C++ used to create a list of base class pointers and call methods of any of the derived classes without even knowing kind of derived class object. Virtual functions are resolved late, at runtime.Here is an implementation of virtual function in C++ program −Example#include using namespace std; class B {    public:       virtual void s() { //virtual function          cout

Why is a Smartphone Called Smart?

Anuradha Nanda
Updated on 30-Jul-2019 22:30:25

826 Views

Why is a smartphone called smart? A very common question strikes our head every now and then when we hear- Smartphone? Well, why not? From internet browsing to road navigations and doing every possible thing online, it has really made our life easier. I don’t think the present smart phone addicted mankind can survive even a single day without its smartphones.What A Smartphone Can DoThese phones are no different than a mini computer. Very much similar to computers, these smartphones also runs on operating systems as well as there are different applications for performing specific tasks in it. Each app is ... Read More

ShortBuffer Compact Method in Java

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

116 Views

The buffer can be compacted using the compact() method in the class java.nio.ShortBuffer. This method does not require a parameter and it returns the new compacted ShortBuffer with the same content as the original buffer. If the buffer is read-only, then the ReadOnlyBufferException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; public class Demo {    public static void main(String[] args) {       int n = 5;       try {          ShortBuffer buffer = ShortBuffer.allocate(n);          buffer.put((short)25);          buffer.put((short)18);   ... Read More

Evaluation of Boolean Expression

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

521 Views

We write a program in 8085 in the assembly language just for the evaluation of only wo Boolean expressions of 4 variables by using the interface of logic controller. The output of the program should be logically tested automatically by the output by the input changing from the inputs from 0000, 0001, … to 1111 just to press any key.Let us say we want to evaluate the following Boolean expressions.First of all, truth table for the Boolean expressions is written down as shown in the following table.PQRSXY000010000100001010001100010010010100011010011100100001100101101010101100110000110111111000111100The inputs of the PQRS gets connected to PB3, PB2, PB1, and PB0 of ... Read More

Advertisements