Let us first create a Java List and add elements −ArrayList < String > list = new ArrayList < String > (); list.add("Katie"); list.add("Tom"); list.add("Jack"); list.add("Amy"); list.add("Andre"); list.add("Brad"); list.add("Peter"); list.add("Bradley");Now, use ListIterator and return the next element in the List with next() −ListIteratoriterator = list.listIterator(); iterator.next();Replace the element in the List with set() method. Here, whatever element is set will get replaced as the first element of the Iterator −iterator.set("Angelina");Example Live Demoimport java.util.ArrayList; import java.util.ListIterator; public class Demo { public static void main(String[] args) { ArrayListlist = new ArrayList(); list.add("Katie"); list.add("Tom"); ... Read More
You can use CAST() with MAX() for this. Since the string is filled with string and integer, fir example, “STU201”, therefore we need to use CAST().Let us first create a table −mysql> create table DemoTable ( Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, StudentBookCode varchar(200) ); Query OK, 0 rows affected (0.56 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(StudentBookCode) values('STU201'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(StudentBookCode) values('STU202'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable(StudentBookCode) values('STU203'); Query OK, 1 row affected (0.20 sec) mysql> ... Read More
The interrupts in 8085 is classified into the following partsThe data transfer scheme: Executing of 8085 program where the communication process is carried out systematically and is not done directly with the Input Output device. The data transfer can be either in two forms namely parallel or serial respectively.Basic or simple data transfer scheme: The simplest data transfer scheme is the basic or simple data transfer. This method is beneficial to us when we have accurate know-ledge of the Input Output device timing characteristics.Status check data transfer: Status check data transfer process is a much more complex process than simple data transfer. We ... Read More
This example demonstrates How to make a txt file in external storage with runtime permission 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 edit text and button. When user click on button, it will take data from edit text and store in external storage.Step 3 − Add the following code to src/MainActivity.javapackage com.example.andy.myapplication; import android.content.pm.PackageManager; import android.os.Build; import android.os.Bundle; import ... Read More
Before getting into an example, we should know what sqlite database in android is. SQLite is an open source SQL database that stores data to a text file on a device. Android comes in with built-in SQLite database implementation. SQLite supports all the relational database features. In order to access this database, you don't need to establish any kind of connections for it like JDBC, ODBC etc.This example demonstrates about How to use unixepoch in Android sqliteStep 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a ... Read More
Stored procedures are sub routines, segment of SQL statements which are stored in SQL catalog. All the applications that can access Relational databases (Java, Python, PHP etc.), can access stored procedures.Stored procedures contain IN and OUT parameters or both. They may return result sets in case you use SELECT statements. Stored procedures can return multiple result sets.Creating a Stored procedureSuppose, we have created a table named Employee in MySQL database as shown below:String createTable = "CREATE TABLE Employee(" + "Name VARCHAR(255), " + "Salary INT NOT NULL, " + "Location VARCHAR(255))";Following is an example of a MySQL ... Read More
This example demonstrates How to Set OnClick Listener on Action Bar Title 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 toolbar and text view.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.annotation.SuppressLint; import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; ... Read More
The current instant from the system UTC clock can be obtained using the now() method in the Instant class in Java. This method requires no parameters and it returns the current instant from the system UTC clock.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { Instant i = Instant.now(); System.out.println("The current Instant is: " + i); } }OutputThe current Instant is: 2019-02-12T11:49:22.455ZNow let us understand the above program.The current instant from the system UTC clock is obtained using the ... Read More
To set auto increment initial value for MySQL table, use ALTER command. The first step would bealter table yourTableName modify yourColumnName int NOT NULL AUTO_INCREMENT PRIMARY KEY, add index(yourColumnName);The second step is as followsalter table yourTableName AUTO_INCREMENT=yourStartingValue;To understand the above syntax, let us create a table. The query to create a table is as followsmysql> create table setAutoIncrementDemo -> ( -> UserId int, -> UserName varchar(20) -> ); Query OK, 0 rows affected (0.75 sec)Now implement the above two steps to set auto increment initial value for MySQL table.Step 1 -The query is as followsmysql> alter ... Read More
NodeJs and Python are two main preferred languages among developers and web designers. But there are couple of areas where NodeJs fall short of python are numerical and scientic computation (AI, Machine learning, deep learning etc.). Whereas python provides lots of libraries to work with scientific computing lot easier.Luckly, we can utilise the python libraries within our nodejs application by running python in the background and return back the result.For this we are going to use the child_process standard library of NodeJs to spawn a pyton process in the background, do computation and return back the result to our node ... Read More