Karthikeya Boyini has Published 2383 Articles

ByteBuffer asIntBuffer() method in Java

karthikeya Boyini

karthikeya Boyini

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

65 Views

A view of the ByteBuffer can be created as an IntBuffer using the asIntBuffer() method in the class java.nio.ByteBuffer. This method requires no parameters and it returns an int buffer as required. This buffer reflects the changes made to the original buffer and vice versa.A program that demonstrates this is ... Read More

How to get the Checksum of a Byte Array in Java?

karthikeya Boyini

karthikeya Boyini

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

962 Views

Create a Byte Array for which you want the Checksum −byte[] arr = "This is it!".getBytes();Now, create a Checksum object −Checksum checksum = new Adler32(); checksum.update(arr, 0, arr.length);The update() above updates the current checksum with the specified array of bytes.Now, get the checksum with getValue() method, which gives the current ... Read More

How do you select from MySQL where last value in a string = x?

karthikeya Boyini

karthikeya Boyini

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

163 Views

You can use LIKE operator with wildcards to select the records where last value in a string = x, for example ‘10’, ‘15’, etc.Let us first create a table −mysql> create table DemoTable (    ClientId varchar(20) ); Query OK, 0 rows affected (0.68 sec)Insert records in the table using ... Read More

How does a vector work in C++?

karthikeya Boyini

karthikeya Boyini

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

242 Views

Vectors have the ability to resize itself automatically like dynamic arrays when an element is inserted or deleted, the container handle their storage automatically. Vector elements are placed in contiguous storage so that they can be accessed and traversed using iterators. Data can be inserted or erased at the begin, ... Read More

CharBuffer put() method in Java

karthikeya Boyini

karthikeya Boyini

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

70 Views

The required value can be written at the current position of the buffer and then the current position is incremented using the method put() in the class java.nio.CharBuffer. This method requires a single parameter i.e. the value to be written in the buffer and it returns the buffer in which ... Read More

Java Program to convert java.util.Date to ZonedDateTime

karthikeya Boyini

karthikeya Boyini

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

3K+ Views

Create a Date object −Date date = new Date();Now, set the ZonedId to default −final ZoneId id = ZoneId.systemDefault();Convert java.util.date to ZonedDateTime −System.out.println(ZonedDateTime.ofInstant(date.toInstant(), id));Example Live Demoimport java.time.ZoneId; import java.time.ZonedDateTime; import java.util.Date; public class Demo {    public static void main(String[] args) {       Date date = new Date();   ... Read More

Rename file or directory in Java

karthikeya Boyini

karthikeya Boyini

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

311 Views

The method java.io.File.renameTo() is used to rename a file or directory. This method requires a single parameter i.e. the name that the file or directory is renamed to and it returns true on the success of the renaming or false otherwise.A program that demonstrates this is given as follows −Example Live ... Read More

LocalTime plusHours() method in Java

karthikeya Boyini

karthikeya Boyini

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

34 Views

An immutable copy of a LocalTime object where some hours are added to it can be obtained using the plusHours() method in the LocalTime class in Java. This method requires a single parameter i.e. the number of hours to be added and it returns the LocalTime object with the added ... Read More

Check the frequency of an element in Java with Collections.frequency

karthikeya Boyini

karthikeya Boyini

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

175 Views

Create a List in Java −List< String >list = Arrays.asList("P", "Q", "R", "P", "T", "P", "U", "V", "W", "X", "W" );Now, let’s say you want to get the frequency of element P. For that, use the Collections.frequency() method −Collections.frequency(list, "P");A shown above, we can find the occurrence of any letter ... Read More

Do Double Equal Sign exist in MySQL?

karthikeya Boyini

karthikeya Boyini

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

2K+ Views

There is no double equal sign concept. It can be used to compare two values. If you use double equal sign(==) in MySQL, you will get an error message.Let us verify the concept is true or not. Declare a variable −mysql> set @Number=10; Query OK, 0 rows affected (0.00 sec)Now, ... Read More

Advertisements