Karthikeya Boyini has Published 2383 Articles

LocalDateTime getHour() method in Java

karthikeya Boyini

karthikeya Boyini

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

86 Views

The hour of the day for a particular LocalDateTime can be obtained using the getHour() method in the LocalDateTime class in Java. This method requires no parameters and it returns the hour of the day which can range from 0 to 23.A program that demonstrates this is given as follows ... Read More

Java Program to add and remove elements from a set which maintains the insertion order

karthikeya Boyini

karthikeya Boyini

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

384 Views

Create a LinkedHashSet −LinkedHashSetset = new LinkedHashSet();Now, add elements to the Set −set.add(20); set.add(60); set.add(80); set.add(120); set.add(150); set.add(200);For removing the elements −set.remove(150); set.remove(260);Above process of insertion and deletion won’t affect the insertion order.Example Live Demoimport java.util.LinkedHashSet; public class Demo {    public static void main(String[] args) {       LinkedHashSetset ... Read More

Finding only strings beginning with a number using MySQL Regex?

karthikeya Boyini

karthikeya Boyini

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

227 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 ... Read More

Java Program to close this input stream and release any system resources associated with the stream

karthikeya Boyini

karthikeya Boyini

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

137 Views

The method java.io.InputStream.close() is used to close this input stream and release any system resources associated with the stream. This method requires no parameters and returns no value. Also, the IOException is thrown when an I/O error occurs.A program that demonstrates this is given as follows −Example Live Demoimport java.io.FileInputStream; import ... Read More

CharBuffer compareTo() method in Java

karthikeya Boyini

karthikeya Boyini

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

74 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 ... Read More

A Protocol Using Selective Repeat

karthikeya Boyini

karthikeya Boyini

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

10K+ Views

Selective repeat protocol, also called Selective Repeat ARQ (Automatic Repeat reQuest), is a data link layer protocol that uses sliding window method for reliable delivery of data frames. Here, only the erroneous or lost frames are retransmitted, while the good frames are received and buffered.It uses two windows of equal ... Read More

Java Program to read the next byte of data from the input stream

karthikeya Boyini

karthikeya Boyini

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

333 Views

The method java.io.InputStream.read() is used to read the next byte of data from the input stream. This method requires no parameters and it returns the next data byte in the form of int. If the stream end is reached, it returns -1.A program that demonstrates this is given as follows ... Read More

Java Program to create a new list with values from existing list with Lambda Expressions

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

To create a new list with values from existing list with Lambda Expressions, the following is an example.Here, we are displaying the name of Employees. Therefore, we have created an Employee class as well −Listemp = Arrays.asList(new Employee("Jack", 29, "South"), new Employee("Tom", 24, "North"), new Employee("Harry", 35, "West"), new Employee("Katie", ... Read More

MySQL UPDATE using IF condition

karthikeya Boyini

karthikeya Boyini

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

9K+ Views

The syntax is as follows to perform UPDATE using IF condition in MySQL −update yourTableName set yourColumnName =if(yourColumnName =yourOldValue, yourNewValue, yourColumnName);To understand the above syntax, let us create a table. The query to create a table is as follows −mysql> create table updateIfConditionDemo    -> (    -> UserId int ... Read More

How to initialize a vector in C++?

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

Initialization vector can be done in many ways1) Initialize a vector by push_back() methodAlgorithmBegin    Declare v of vector type.    Call push_back() function to insert values into vector v.    Print “Vector elements:”.    for (int a : v)       print all the elements of variable a. ... Read More

Advertisements