Following is the syntax to add column using alter in MySQL:alter table yourTableName add column yourColumnName yourDataType default yourValue;Let us first create a table:mysql> create table alterTableDemo -> ( -> Id int, -> Name varchar(10) -> ); Query OK, 0 rows affected (0.69 sec)Let us check the description of the table using DESC command. This displays Field, Type, Key, etc. of the table:mysql> desc alterTableDemo;This will produce the following output+-------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-------+-------------+------+-----+---------+-------+ | Id | int(11) | YES ... Read More
This is a C++ program to represent Linear Equations in matrix form.AlgorithmBegin 1) Take the no of variables n and the coefficients of each variable as input. 2) Declare a matrix[n][n] and constant[n][1]. 3) Make for loops i = 0 to n-1 and j = 0 to n-1 to take the coefficients of each variable as the elements of the matrix. 4) Display the matrix by using nested for loops. EndExample#include using namespace std; int main(void) { char variable[] = { 'x', 'y', 'z', 'd' }; cout > n; cout > matrix[i][j]; } cin >> constant[i][0]; } cout
To extract filenames from a path MySQL, you can use SUBSTRING_INDEX(). The syntax is as follows −SELECT SUBSTRING_INDEX(ypurColumnName, '\', -1) as anyAliasName FROM yourTableName;To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table ExtractFileNameDemo -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> AllProgrammingFilePath varchar(100) -> ); Query OK, 0 rows affected (0.50 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into ExtractFileNameDemo(AllProgrammingFilePath) ... Read More
The instant of the base clock can be rounded off for the required duration using the method tick() in the Clock Class in Java. This method requires two parameters i.e. the base clock and the duration of the tick. Also, the instant of the base clock rounded off for the required duration is returned.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main { public static void main(String[] args) { Clock bClock = Clock.systemDefaultZone(); Instant i = bClock.instant(); System.out.println("The Instant of the base clock is: ... Read More
To search a value in Unit class in JavaTuples, use the contains() method.Let us first see what we need to work with JavaTuples. To work with the Unit class in JavaTuples, you need to import the following package −import org.javatuples.Unit;Note − Steps to download and run JavaTuples program If you are using Eclipse IDE to run Unit Class in Java Tuples, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file.The following is an example −Exampleimport org.javatuples.Unit; public class Demo { public static void main(String[] args) { ... Read More
This example demonstrate about How to remove data from treemap to arraylist for listview 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 the name and record number as Edit text, when user click on save button it ... Read More
This example demonstrate about How to get information about USB mounted or not 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 USB mount information.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.KeyguardManager; import android.content.Context; import android.net.ConnectivityManager; import android.net.Network; import android.net.NetworkInfo; import android.os.Build; import android.os.Bundle; import android.os.Environment; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.widget.TextView; public class ... Read More
The anyMatch() method of the DoubleStream class returns whether any elements of this stream match the provided predicate.The syntax is as followsboolean anyMatch(DoublePredicate predicate)Here, the parameter predicate is a stateless predicate to apply to elements of this stream. The DoublePredicate here is a predicate of one double-valued argument.To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;Create a DoubleStream and add some elements to the streamDoubleStream doubleStream = DoubleStream.of(67.9, 89.9, 10.5, 95.8, 49.6);Now, check if any of the elements match the predicateboolean res = doubleStream.anyMatch(a -> a > 50);The following is an example to implement DoubleStream anyMatch() method ... Read More
To create a Decade Tuple in Java, you can use the with() method. Let us first see what we need to work with JavaTuples. To work with Decade class in JavaTuples, you need to import the following package.import org.javatuples.Decade;Note: Download JavaTuples Jar library to run JavaTuples program. If you are using Eclipse IDE, then Right Click Project → Properties → Java Build Path → Add External Jars and upload the downloaded JavaTuples jar file. Refer the below guide for all the steps to run JavaTuples.Steps: How to run JavaTuples program in EclipseThe following is an example to create Decade Tuple ... Read More
AVL tree is a self-balancing Binary Search Tree where the difference between heights of left and right subtrees cannot be more than one for all nodesTree rotation is an operation that changes the structure without interfering with the order of the elements on an AVL tree. It moves one node up in the tree and one node down. It is used to change the shape of the tree, and to decrease its height by moving smaller subtrees down and larger subtrees up, resulting in improved performance of many tree operations. The direction of a rotation depends on the side which ... Read More