Check If MySQL Database Is Empty

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

2K+ Views

You can use INFORMATION_SCHEMA.COLUMNS to check if a database is empty or not. The syntax is as follows −SELECT COUNT(DISTINCT `TABLE_NAME`) AS anyAliasName FROM `INFORMATION_SCHEMA`.`COLUMNS` WHERE `table_schema` = 'yourDatabaseName';The above syntax returns 0 if the database has notable otherwise it returns the number of tables. For our example, we are using the databases ‘sample’ and ‘test3’, which we created before.The first database ‘sample’ has more tables, therefore the above query will return a number of tables. The second database ‘test3’ does not have any tables, therefore the above query will return 0.Case 1 − Database sampleThe query is as follows ... Read More

Get Current Postal Code from Network Provider in Android

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

652 Views

This example demonstrates about How to get the current postal code 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 postal code information.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

Use Action Down Event in Android

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

378 Views

 This example demonstrate about How use action down event 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 perform action down event.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.SuppressLint; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v4.view.MotionEventCompat; import android.support.v7.app.AppCompatActivity; import android.view.MotionEvent; import android.view.View; import android.widget.TextView; import android.widget.Toast; public class MainActivity extends AppCompatActivity {   ... Read More

DoubleStream Sequential Method in Java

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

108 Views

The sequential() method of the DoubleStream class returns an equivalent stream that is sequential.The syntax is as followsDoubleStream sequential()To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;Create a DoubleStream and add some elementsDoubleStream doubleStream1 = DoubleStream.of(45.8, 67.9, 78.5, 90.6, 97.4);Now create an equivalent stream that is sequentialDoubleStream doubleStream2 = doubleStream1.sequential();The following is an example to implement DoubleStream sequential() method in JavaExample Live Demoimport java.util.*; import java.util.stream.DoubleStream; public class Demo {    public static void main(String[] args) {       DoubleStream doubleStream1 = DoubleStream.of(45.8, 67.9, 78.5, 90.6, 97.4);       DoubleStream doubleStream2 = doubleStream1.sequential();       ... Read More

Why C Treats Array Parameters as Pointers

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

297 Views

C treats array parameter as pointers because it is less time consuming and more efficient. Though if we can pass the address of each element of the array to a function as argument but it will be more time consuming. So it’s better to pass the base address of first element to the function like:void fun(int a[]) { … } void fun(int *a) { //more efficient. ….. }Here is a sample code in C:#include void display1(int a[]) //printing the array content {    int i;    printf("Current content of the array is: ");    for(i = 0; i < ... Read More

ArrayBlockingQueue Poll Method in Java

Krantik Chavan
Updated on 30-Jul-2019 22:30:25

202 Views

The poll() method of the ArrayBlockingQueue class in Java retrieves and removes the head of this queue, or returns null if this queue is empty.The syntax is as follows:E poll()To work with ArrayBlockingQueue class, you need to import the following package:import java.util.concurrent.ArrayBlockingQueue;The following is an example to implement poll() method of Java ArrayBlockingQueue class:Example Live Demoimport java.util.concurrent.ArrayBlockingQueue; public class Demo {    public static void main(String[] args) throws InterruptedException {       ArrayBlockingQueue q = new ArrayBlockingQueue(10);       q.add(200);       q.add(310);         q.add(400);       q.add(450);       q.add(500);     ... Read More

Difference Between ++p, p++, and ++p in C++

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

1K+ Views

In this section we will see what are the differences between *ptr++, *++ptr and ++*ptr in C++.Here we will see the precedence of postfix++ and prefix++ in C or C++. The precedence of prefix ++ or -- has higher priority than dereference operator ‘*’ and postfix ++ or -- has priority higher than both prefix ++ and dereference operator ‘*’.When ptr is a pointer, then *ptr++ indicates *(ptr++) and ++*prt refers ++(*ptr)Example Code Live Demo#include using namespace std; int main() { char arr[] = "Hello World"; char *ptr = arr; ++*ptr; cout

Use Pool in Android LinkedBlockingDeque

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

149 Views

Before getting into an example, we should know what LinkedBlockingDeque is. It is implemented by Collection interface and the AbstractQueue class. It provides optional boundaries based on linked nodes.It going to pass memory size to a constructor and helps to provide memory wastage in android.This example demonstrates about How to use pool() in android LinkedBlockingDequeStep 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 ... Read More

What is a Litecoin

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

265 Views

Just like our fiat currency, we have dozens of cryptocurrencies which are ruling the digital world now. Litecoin is created based on an open source cryptographic protocol and was started in October 2011 as an early bitcoin spinoff. It is a decentralized money, free from censorship and used to send secure payments digitally.According to the market capitalization, LiteCoin is the third largest cryptocurrency after BitCoin and XRP, and like other cryptocurrencies, Litecoins does not allow transactions in US Dollars. They conduct transactions in Litecoin units.The total number of Litecoins that can ever be mined is capped at 84 million. The ... Read More

Insert Value to a SortedSet in Java

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

172 Views

Let’s say we have the following SortedSet −SortedSet set = new TreeSet(); set.add("T"); set.add("R"); set.add("S"); set.add("Q"); set.add("V"); set.add("U"); set.add("W");Now, after displaying the above elements with Iterator, you can insert values like this to a SortedSetset.add("Z"); set.add("Y");Example Live Demoimport java.util.Iterator; import java.util.SortedSet; import java.util.TreeSet; public class Demo {    public static void main(String[] argv) throws Exception {       SortedSet set = new TreeSet();       set.add("T");       set.add("R");       set.add("S");       set.add("Q");       set.add("V");       set.add("U");       set.add("W");       Iterator i = set.iterator();     ... Read More

Advertisements