Get Phone Number in Android

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

5K+ Views

This example demonstrate about How to get phone number 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. When user open application, Phone number going to append on textview.Step 3 − Add the following code to src/MainActivity.java.package com.example.andy.myapplication; import android.Manifest; import android.content.Context; import android.content.pm.PackageManager; 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 android.telephony.TelephonyManager; import android.widget.TextView; import ... Read More

Apply if Tag in JSP

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

278 Views

The tag evaluates an expression and displays its body content only if the expression evaluates to true.AttributeThe tag has the following attributes −AttributeDescriptionRequiredDefaulttestCondition to evaluateYesNonevarName of the variable to store the condition's resultNoNonescopeScope of the variable to store the condition's resultNopageExample Tag Example My salary is: The above code will generate the following result −My salary is: 4000

LocalDate.now() Method in Java

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

281 Views

The current date can be obtained from the system clock in the default time zone using the now() method in the LocalDate class in Java. This method requires no parameters and it returns the current date from the system clock in the default time zoneA program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Demo { public static void main(String[] args) { LocalDate ld = LocalDate.now(); System.out.println("The LocalDate is: " + ld); } }OutputThe LocalDate is: 2019-02-15Now let ... Read More

IntStream mapToDouble Method in Java

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

931 Views

The mapToDouble() method returns a DoubleStream consisting of the results of applying the given function to the elements of this stream.The syntax is as follows.DoubleStream mapToDouble(IntToDoubleFunction mapper)Here, the parameter mapper is the stateless function applied to each element.Create an IntStream with some elements.IntStream intStream = IntStream.of(5, 20, 25, 45, 60, 75, 85, 90);Now, use the mapToDouble() method to return a DoubleStream.DoubleStream doubleStream = intStream.mapToDouble(val -> (double) val);The following is an example to implement IntStream mapToDouble() method in Java.Example Live Demoimport java.util.*; import java.util.stream.IntStream; import java.util.stream.DoubleStream; public class Demo {    public static void main(String[] args) {       IntStream intStream ... Read More

View Auto Increment Value for a Table in MySQL

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

2K+ Views

In order to view the auto_increment value for a table, you can use SHOW TABLE command.The syntax is as followsSHOW TABLE STATUS LIKE 'yourTableName'\GThe syntax is as followsSELECT `AUTO_INCREMENT`    FROM `information_schema`.`TABLES`    WHERE `TABLE_SCHEMA` = ‘yourDatabaseName’    AND `TABLE_NAME` =’yourTableName';To understand the above syntaxes, let us create a table. The query to create a table is as followsmysql> create table viewAutoIncrementDemo    -> (    -> UserId int NOT NULL AUTO_INCREMENT PRIMARY KEY,    -> UserName varchar(20)    -> ); Query OK, 0 rows affected (0.59 sec)Now you can insert some records in the table using insert command. The ... Read More

Check Sub-tree of a Binary Tree in C++

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

257 Views

A binary tree is a tree data structure in which each node has at most two children, which are defined as left child and right child.AlgorithmBegin    function identical():        Take two nodes r1 and r2 as parameter.       If r1 and r2 is NULL then          Return true.       If r1 or r2 is NULL then          Return false.       Return (r1->d is equal to r2->d and          Call function Identical(r1->l, r2->l) and          Call functions Identical(r1->r, r2->r) ); ... Read More

Update Value of a Key in a List of JSON in MongoDB

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

775 Views

Let us first create a collection with documents> db.updateListOfKeyValuesDemo.insertOne( { "StudentDetails":[ { "StudentName":"John", "StudentAge":23, "StudentCountryName":"US" }, { "StudentName":"Carol", "StudentAge":24, "StudentCountryName":"UK" }, { "StudentName":"Bob", "StudentAge":22, "StudentCountryName":"AUS" } ] } ); {    "acknowledged" : true,    "insertedId" : ObjectId("5c9b5b759882024390176545") }Following is the query to display all documents from a collection with the help of find() method> db.updateListOfKeyValuesDemo.find().pretty();This will produce the following output{    "_id" : ObjectId("5c9b5b759882024390176545"),    "StudentDetails" : [       {          "StudentName" : "John",          "StudentAge" : 23,          "StudentCountryName" : "US"       },     ... Read More

Generate Random BigInteger Value in Java

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

3K+ Views

To generate random BigInteger in Java, let us first set a min and max value −BigInteger maxLimit = new BigInteger("5000000000000"); BigInteger minLimit = new BigInteger("25000000000");Now, subtract the min and max −BigInteger bigInteger = maxLimit.subtract(minLimit); Declare a Random object and find the length of the maxLimit: Random randNum = new Random(); int len = maxLimit.bitLength();Now, set a new B integer with the length and the random object created above.Example Live Demoimport java.math.BigInteger; import java.util.Random; public class Demo {    public static void main(String[] args) {       BigInteger maxLimit = new BigInteger("5000000000000");       BigInteger minLimit = new BigInteger("25000000000");   ... Read More

Print Numbers from 1 to 1000 Without Loops or Conditionals in C/C++

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

583 Views

Here we will see how to print 1 to 1000 without loop or any conditional statements. As the loops cannot be used, so we can try recursions, but here another constraint that, we cannot use the conditions also. So the base case of the recursion will not be used.Here we are solving this problem using static members. At first we are initializing the static member with 1, then in the constructor we are printing the value and increase its value. Now create an array of 1000 objects of that class, so 1000 different objects are created, so the constructor is ... Read More

Resolve Error 1111: Invalid Use of Group Function in MySQL

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

2K+ Views

To correctly use aggregate function with where clause in MySQL, the following is the syntax −select *from yourTableName where yourColumnName > (select AVG(yourColumnName) from yourTableName);To understand the above concept, let us create a table. The query to create a table is as follows −mysql> create table EmployeeInformation    -> (    -> EmployeeId int,    -> EmployeeName varchar(20),    -> EmployeeSalary int,    -> EmployeeDateOfBirth datetime    -> ); Query OK, 0 rows affected (1.08 sec)Now you can insert some records in the table using insert command. The query is as follows −mysql> insert into EmployeeInformation values(101, 'John', 5510, '1995-01-21'); ... Read More

Advertisements