Instant plusSeconds Method in Java

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

590 Views

An immutable copy of a instant where some seconds are added to it can be obtained using the plusSeconds() method in the Instant class in Java. This method requires a single parameter i.e. the number of seconds to be added and it returns the instant with the added seconds.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);       System.out.println("An instant with 10 seconds added is: " + ... Read More

Smallest Data Type for One Bit in MySQL

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

188 Views

The smallest datatype for one bit can be bit(1). The syntax is as follows −yourColumnName bit(1)To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table bitDemo    -> (    -> isValid bit(1)    -> ); Query OK, 0 rows affected (0.49 sec)Now you can check all the details of table with the help of SHOW CREATE command. The query is as follows −mysql> show create table bitDemo;Here is the output −+---------+-----------------------------------------------------------------------------------------------------------------------------+ | Table   | Create Table   ... Read More

Printing Heart Pattern in C

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

9K+ Views

In this program we will see how to print heart shaped pattern in C. The heart shape pattern will be look like thisNow if we analyze this pattern, we can find different section in this pattern. The base of the heart is an inverted triangle; the upper portion has two different peaks. Between these two peaks there is a gap. To make this pattern we have to manage these parts into our code to print the pattern like this.Example Live Demo#include int main() {    int a, b, line = 12;    for (a = line/2; a

Write MySQL Procedure to Insert Data into a Table

Smita Kapse
Updated on 30-Jul-2019 22:30:25

701 Views

To write stored procedure to insert data into a table, at first you need to create a table −mysql> create table insertDataUsingStoredProcedure    -> (    -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY ,    -> Name varchar(20),    -> Age int    -> ); Query OK, 0 rows affected (0.51 sec)Following is the query to write stored procedure to insert data into the table −mysql> DELIMITER // mysql> CREATE PROCEDURE StoredProcedureInsertData(IN StudentName varchar(100), IN StudentAge int)    -> BEGIN    -> insert into insertDataUsingStoredProcedure(Name, Age) values (StudentName, StudentAge );    -> END    -> // Query OK, 0 ... Read More

Create String to Super Class Type Mapping in Java

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

188 Views

Here, we have a superclass Vehicle and within that some subclasses −class Vehicle { } class Motorcycle extends Vehicle { } class Bus extends Vehicle { } class Car extends Vehicle { }Now, we will create some strings for mapping with super class type −Mapmap = new HashMap(); map.put("motorcycle", new Motorcycle()); map.put("bus", new Bus()); map.put("car", new Car());Example Live Demoimport java.util.HashMap; import java.util.Map; class Vehicle { } class Motorcycle extends Vehicle { } class Bus extends Vehicle { } class Car extends Vehicle { } public class Demo {    public static void main(String... args) {       Mapmap = new ... Read More

Add a New Column to a MySQL Query and Assign a Value

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

13K+ Views

To add column to MySQL query and give it a value, use the below syntax −select yourColumnName1, yourColumnName2, .....N ,yourValue AS anyAliasName from yourTableName;Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    FirstName varchar(20) ); Query OK, 0 rows affected (0.84 sec)Insert some records in the table using insert command −mysql> insert into DemoTable(FirstName) values('John'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable(FirstName) values('Larry'); Query OK, 1 row affected (0.17 sec) mysql> insert into DemoTable(FirstName) values('Chris'); Query OK, 1 row affected (0.14 sec) mysql> insert into ... Read More

Filtering Images Based on Size Attributes in Python

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

306 Views

Python provides multiple libraries for image processing including Pillow, Python Imaging library, scikit-image or OpenCV.We are going to use Pillow library for image processing here as it offers multiple standard procedures for image manipulation and supports the range of image file formats such as jpeg, png, gif, tiff, bmp and others.Pillow library is built on top of Python Imaging Library(PIL) and provides more features than its parent library(PIL).InstallationWe can install pillow using pip, so just type following in the command terminal −$ pip install pillowBasic operation on a pillowLet’s some basic operation on images using pillow library.from PIL import Image ... Read More

Order of Libraries and Errors in GCC

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

185 Views

Basically this kind of errors are originated from the linker in the compilation phase. The default behavior of a linker is to take the code from archive libraries when the current program needs it.To work properly the libraries must be present in order. We can say that it must be there in the form “caller before callees”. This problem can be solved by choosing non-default behavior using flags, but in this process the linking may take larger time. Otherwise it can be solved by ordering the libraries correctly. Loaders and tsort these two can help to rearrange and correct the ... Read More

Difference Between execute, executeQuery and executeUpdate Methods in JDBC

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

21K+ Views

Once you have created the statement object you can execute it using one of the execute methods of the Statement interface namely, execute(), executeUpdate() and, executeQuery().The execute() method: This method is used to execute SQL DDL statements, it returns a boolean value specifying weather the ResultSet object can be retrieved.Exampleimport java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class Example {    public static void main(String args[]) throws SQLException {       //Registering the Driver       DriverManager.registerDriver(new com.mysql.jdbc.Driver());       //Getting the connection       String mysqlUrl = "jdbc:mysql://localhost/sampleDB";       Connection con = ... Read More

Set Subtitle for Action Bar in Android

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

941 Views

This example demonstrates How to set subtitle for action bar 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 status bar sub tittle.Step 3 − Add the following code to src/MainActivity.javapackage com.example.myapplication; import android.app.ActivityManager; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; import android.os.Build; import android.os.Bundle; import android.support.annotation.RequiresApi; import android.support.v7.app.AppCompatActivity; import android.view.View; import android.widget.TextView; public class MainActivity extends ... Read More

Advertisements