Karthikeya Boyini has Published 2193 Articles

CharBuffer arrayOffset() method in Java

karthikeya Boyini

karthikeya Boyini

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

105 Views

The offset of the first element of the buffer inside the buffer array is obtained using the method arrayOffset() in the class java.nio.CharBuffer. If the buffer backed by the array is read-only, then the ReadOnlyBufferException is thrown.A program that demonstrates this is given as follows −Example Live Demoimport java.nio.*; import java.util.*; ... Read More

LocalDateTime getHour() method in Java

karthikeya Boyini

karthikeya Boyini

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

153 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

Finding only strings beginning with a number using MySQL Regex?

karthikeya Boyini

karthikeya Boyini

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

395 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

CharBuffer compareTo() method in Java

karthikeya Boyini

karthikeya Boyini

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

129 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

12K+ 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

441 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

MySQL UPDATE using IF condition

karthikeya Boyini

karthikeya Boyini

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

10K+ 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

Format date in MySQL to return MonthName and Year?

karthikeya Boyini

karthikeya Boyini

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

134 Views

Use DATE_FORMAT() and set the specifiers to display only the MonthName and Year. Let us first create a table −mysql> create table DemoTable (    Id int NOT NULL AUTO_INCREMENT PRIMARY KEY,    AdmissionDate date ); Query OK, 0 rows affected (0.69 sec)Insert records in the table using insert command ... Read More

Custom ArrayList in Java

karthikeya Boyini

karthikeya Boyini

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

971 Views

A custom ArrayList can have multiple types of data and its attributes in general are based on the user requirements.A program that demonstrates a custom ArrayList is given as follows −Example Live Demoimport java.util.ArrayList; public class CustomArrayList {    int n = 5;    class Employee {       int ... Read More

How to create Java Priority Queue to ignore duplicates?

karthikeya Boyini

karthikeya Boyini

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

1K+ Views

The simplest way to create a Java Priority Queue to ignore duplicates is to first create a Set implementation −HashSet set = new HashSet (); set.add(100); set.add(150); set.add(250); set.add(300); set.add(250); set.add(500); set.add(600); set.add(500); set.add(900);Now, create Priority Queue and include the set to remove duplicates in the above set ... Read More

Advertisements