Navigate Through a ResultSet Using a JDBC Program

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

238 Views

The next() method of the ResultSet interface moves the pointer/Cursor of the current ResultSet object to the next row from the current position. This method returns a boolean value. If there are no rows next to its current position this method returns false, else it returns true.Therefore, using this method in the while loop you can iterate the contents of the ResultSet object.while(rs.next()){ }Getting the column values of each recordThe ResultSet interface (also) provides getter methods (getXXX()) to retrieve values in each column of a row, each getter methods has two variants:getXXX(int columnIndex): Accepts an integer value representing the index ... Read More

Find Current Bluetooth Supports LE2MPY in Android

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

111 Views

This example demonstrate about How to find current Bluetooth supports Le2MPy 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 Bluetooth status about Le2MPy.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.bluetooth.BluetoothManager; import android.content.Context; import android.net.ConnectivityManager; import android.net.Network; import android.os.Build; import android.os.Bundle; import android.os.health.SystemHealthManager; import android.provider.Telephony; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.telephony.SmsManager; import android.view.View; import ... Read More

LocalDate isBefore Method in Java

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

800 Views

It can be checked if a particular LocalDate is before the other LocalDate in a timeline using the isBefore() method in the LocalDate class in Java. This method requires a single parameter i.e. the LocalDate object that is to be compared. It returns true if the LocalDate object is before the other LocalDate object and false otherwise.A program that demonstrates this is given as follows −Example Live Demoimport java.time.*; public class Main {    public static void main(String[] args) {       LocalDate ld1 = LocalDate.parse("2019-02-12");       LocalDate ld2 = LocalDate.parse("2019-02-14");       System.out.println("The LocalDate ld1 is: ... Read More

DoubleStream Iterator Method in Java

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

142 Views

The iterator() method of the DoubleStream class in Java returns an iterator for the elements of this stream.The syntax is as followsPrimitiveIterator.OfDouble iterator()Here, PrimitiveIterator.OfDouble is an Iterator specialized for double values.To use the DoubleStream class in Java, import the following packageimport java.util.stream.DoubleStream;The following is an example to implement DoubleStream iterator() method in JavaExample Live Demoimport java.util.*; import java.util.stream.DoubleStream; public class Demo {    public static void main(String[] args) {       DoubleStream doubleStream = DoubleStream.of(50.6, 69.8, 81.8, 95.6, 106.9);       PrimitiveIterator.OfDouble res = doubleStream.iterator();       while (res.hasNext()) {          System.out.println(res.nextDouble());       }    } }Output50.6 69.8 81.8 95.6 106.9

Select from MySQL Table A That Does Not Exist in Table B

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

2K+ Views

You can use IN operator to select from one table that does not exist in another. To understand the above syntax, let us create a table.The first table name is A and second table name is B. The query to create a table is as followsmysql> create table A    -> (    -> Value int    -> ); Query OK, 0 rows affected (0.56 sec)Now you can insert some records in the table using insert command.The query is as followsmysql> insert into A values(10); Query OK, 1 row affected (0.23 sec) mysql> insert into A values(20); Query OK, 1 ... Read More

IntStream summaryStatistics Method in Java

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

609 Views

The summaryStatistics() method in the IntStream class is used to return summary data about the elements of this stream. The syntax is as follows:IntSummaryStatistics summaryStatistics()Create an IntStream and add some elements:IntStream intStream = IntStream.of(30, 60, 90);Now, get the summary data about the above elements:IntSummaryStatistics details = intStream.summaryStatistics();The following is an example to implement IntStream summaryStatistics() method in Java:Example Live Demoimport java.util.stream.IntStream; import java.util.IntSummaryStatistics; public class Demo {    public static void main(String[] args) {       IntStream intStream = IntStream.of(30, 60, 90);       IntSummaryStatistics details = intStream.summaryStatistics();       System.out.println("Details = "+details);    } }OutputDetails = IntSummaryStatistics{count=3, ... Read More

Use put() in Android PriorityBlockingQueue

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

126 Views

Before getting into the example, we should know what PriorityBlockingQueue is. It is an unbounded queue and follows the same order as a priority queue. The main usage of priority blocking queue is, it going to handle out of memory error.This example demonstrates about How to use put() in android PriorityBlockingQueueStep 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 PriorityBlockingQueue elements.Step ... Read More

Functools: Higher Order Functions and Operations on Callable Objects in Python

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

262 Views

Function in Python is said to be of higher order. It means that it can be passed as argument to another function and/or can return other function as well. The functools module provides important utilities for such higher order functions.partial() functionThis function returns a callable 'partial' object. The object itself behaves like a function. The partial() function receives another function as argument and freezes some portion of a function’s arguments resulting in a new object with a simplified signature.The built-in int() function converts a number to a decimal integer. Default signature of int() isint(x, base = 10)The partial() function can ... Read More

Get Day of Week for Last Day of Each Month in 2019

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

351 Views

For last day of each month, at first create a List collection for day of week −ListdayOfWeek = new ArrayList();Now, get day of week for the last day of each month in 2019, set the year using withYear() and use lastDayOfMonth() and getDayOfWeek methods −for (Month m: Month.values()) {    DayOfWeek days = LocalDate.now().withYear(2019).with(m).with(TemporalAdjusters.lastDayOfMonth()).getDayOfWeek(); }Example Live Demoimport java.time.DayOfWeek; import java.time.LocalDate; import java.time.Month; import java.time.temporal.TemporalAdjusters; import java.util.ArrayList; import java.util.List; public class Demo {    public static void main(String[] argv) {       ListdayOfWeek = new ArrayList();       for (Month m: Month.values()) {          DayOfWeek days = ... Read More

Constructor Delegation in C++

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

1K+ Views

Here we will see what is the constructor delegation? When a constructor calls other constructor of the same class, then it is called the constructor delegation. This feature is present from C++11.Let us see the following program, and try to analyze what are the difficulties in this code.Example#include using namespace std; class MyClass {    int a, b, c;    public:    MyClass(){       a = b = c = 0;    }    MyClass(int c) {       // Initializing a and b are redundent, only c initialization is needed here       a = 0;       b = 0;       this->c = c;    }    void display(){       cout

Advertisements