Print ID of Record in Android SQLite

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

461 Views

Before getting into example, we should know what sqlite data base 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 demonstrate about How to print id of record in Android sqlite.Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details ... Read More

Period plusYears Method in Java

Nancy Den
Updated on 30-Jul-2019 22:30:25

174 Views

An immutable copy of the Period object where some years are added to it can be obtained using the plusYears() method in the Period class in Java. This method requires a single parameter i.e. the number of years to be added and it returns the Period object with the added years.A program that demonstrates this is given as followsExample Live Demoimport java.time.Period; public class Demo {    public static void main(String[] args) {       String period = "P5Y7M15D";       Period p1 = Period.parse(period);       System.out.println("The Period is: " + p1);       Period p2 ... Read More

Get Day of Year using LocalDateTime in Java

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

132 Views

The day of the year for a particular LocalDateTime can be obtained using the getDayOfYear() method in the LocalDateTime class in Java. This method requires no parameters and it returns the day of the year which can be in the range of 1 to 365 and also 366 for leap years.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo {    public static void main(String[] args) {       LocalDateTime ldt = LocalDateTime.parse("2019-02-18T11:30:15");       System.out.println("The LocalDateTime is: " + ldt);       System.out.println("The day of the year is: " + ... Read More

Find Capital Letters with Regex in MySQL

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

546 Views

You can use REGEXP BINARY for thisselect *from yourTableName where yourColumnName REGEXP BINARY '[A-Z]{2}';Let us first create a tablemysql> create table FindCapitalLettrsDemo    -> (    -> StudentId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> StudentFirstName varchar(20)    -> ); Query OK, 0 rows affected (0.52 sec)Insert some records in the table using insert command. The query is as follows −mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('JOHN'); Query OK, 1 row affected (0.24 sec) mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('Carol'); Query OK, 1 row affected (0.15 sec) mysql> insert into FindCapitalLettrsDemo(StudentFirstName) values('bob'); Query OK, 1 row affected (0.14 sec) mysql> insert into ... Read More

DoubleStream Average Method in Java

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

2K+ Views

The average() method of the DoubleStream class in Java returns an OptionalDouble which is the arithmetic mean of elements of this stream. If the stream is empty, empty is returned.The syntax is as follows:OptionalDouble average()Here, OptionalDouble is a container object which may or may not contain a double value.To use the DoubleStream class in Java, import the following package:import java.util.stream.DoubleStream;First, create DoubleStream and add some elements:DoubleStream doubleStream = DoubleStream.of(50.8, 35.7, 49.5, 12.7, 89.7, 97.4);Get the average of the elements of the stream:OptionalDouble res = doubleStream.average();The following is an example to implement DoubleStream average() method in Java:Example Live Demoimport java.util.*; import java.util.stream.DoubleStream; ... Read More

Linear Regression Using Python

Jennifer Nicholas
Updated on 30-Jul-2019 22:30:25

847 Views

Linear regression is one of the simplest standard tool in machine learning to indicate if there is a positive or negative relationship between two variables.Linear regression is one of the few good tools for quick predictive analysis. In this section we are going to use python pandas package to load data and then estimate, interpret and visualize linear regression models.Before we go down further down, let’s discuss what is regression first?What is Regression?Regression is a form of predictive modelling technique which helps in creating a relationship between a dependent and independent variable.Types of RegressionLinear RegressionLogistic RegressionPolynomial RegressionStepwise RegressionWhere is Linear ... Read More

Find Two Random Documents in a MongoDB Collection

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

230 Views

Let us first create a collection and add some documents to it> db.twoRandomDocumentDemo.insertOne({"StudentId":10}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9aad628fa4220163b87") } > db.twoRandomDocumentDemo.insertOne({"StudentId":100}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9add628fa4220163b88") } > db.twoRandomDocumentDemo.insertOne({"StudentId":45}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9b0d628fa4220163b89") } > db.twoRandomDocumentDemo.insertOne({"StudentId":55}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9b3d628fa4220163b8a") } > db.twoRandomDocumentDemo.insertOne({"StudentId":5}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9b7d628fa4220163b8b") } > db.twoRandomDocumentDemo.insertOne({"StudentId":7}); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9ec9bad628fa4220163b8c") }Following is the query to display all documents from a collection with the help of find() method> db.twoRandomDocumentDemo.find();This ... Read More

Find Strings Beginning with a Number Using MySQL Regex

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

436 Views

To find strings beginning with a number, use Regular Expressions. Let us first create a table −mysql> create table DemoTable (    Id varchar(200) ); Query OK, 0 rows affected (0.59 sec)Insert records in the table using insert command −mysql> insert into DemoTable values('123User'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('_$123User'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('User123456'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values('0000User'); Query OK, 1 row affected (0.22 sec) mysql> insert into DemoTable values('&^*User'); Query OK, 1 row affected (0.24 sec)Display records ... Read More

CharBuffer compareTo Method in Java

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

155 Views

A buffer can be compared with another buffer using the method compareTo() in the class java.nio.CharBuffer. This method returns a negative integer if the buffer is less than the given buffer, zero if the buffer is equal to the given buffer and a positive integer if the buffer is greater than the given buffer.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 {       CharBuffer buffer1 = CharBuffer.allocate(n);       buffer1.put('A');       buffer1.put('P'); ... Read More

Convert String to Date in MongoDB

Nancy Den
Updated on 30-Jul-2019 22:30:25

1K+ Views

To convert the string to date in MongoDB, use the following syntax:db.yourCollectionName.aggregate(    [       {          $project:          {             anyVariableName:             {                $dateFromString:                {                   dateString: '$yourFieldName’                }             }          }       }    ] );To understand the above syntax, ... Read More

Advertisements