Karthikeya Boyini has Published 2383 Articles

Java Program to get the reverse of the NavigableSet

karthikeya Boyini

karthikeya Boyini

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

64 Views

We will create a NavigableSet collection and add some elements −NavigableSet set = new TreeSet(); set.add("ABC"); set.add("DEF"); set.add("GHI"); set.add("JKL"); set.add("MNO"); set.add("PQR"); set.add("STU");Now, use descendingSet() for the reverse of NavigableSet −NavigableSetreverse = set.descendingSet();Example Live Demoimport java.util.NavigableSet; import java.util.TreeSet; public class Demo {    public static void main(String[] args) {       ... Read More

LocalDate isBefore() method in Java

karthikeya Boyini

karthikeya Boyini

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

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

How to use put() in android PriorityBlockingQueue?

karthikeya Boyini

karthikeya Boyini

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

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

Java Program to get day of week for the last day of each month in 2019

karthikeya Boyini

karthikeya Boyini

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

245 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()) {   ... Read More

LocalDate isLeapYear() method in Java

karthikeya Boyini

karthikeya Boyini

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

70 Views

It can be checked if the LocalDate is in a leap year or not using the isLeapYear() method in the LocalDate class in Java. This method requires no parameters. It returns true if the LocalDate is in a leap year and false otherwise.A program that demonstrates this is given as ... Read More

How to use remainingCapacity() in android LinkedBlockingDeque?

karthikeya Boyini

karthikeya Boyini

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

60 Views

Before getting into the example, we should know what LinkedBlockingDeque is. It is implemented by Collection interface and the AbstractQueue class. It provides optional boundaries based on linked nodes. It going to pass memory size to a constructor and helps to provide memory wastage in android.This example demonstrates about How ... Read More

Java Program to adjust LocalDate to first Day of Month with TemporalAdjusters class

karthikeya Boyini

karthikeya Boyini

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

814 Views

Let us first set a date −LocalDate localDate = LocalDate.of(2019, Month.APRIL, 10);Now, adjust LocalDate to first Day of Month −LocalDate day = localDate.with(TemporalAdjusters.firstDayOfMonth());Example Live Demoimport java.time.LocalDate; import java.time.Month; import java.time.temporal.TemporalAdjusters; public class Demo {    public static void main(String[] args) {       LocalDate localDate = LocalDate.of(2019, Month.APRIL, 10);   ... Read More

FloatBuffer asReadOnlyBuffer() method in Java

karthikeya Boyini

karthikeya Boyini

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

49 Views

A read-only float buffer can be created using the contents of a buffer with the method asReadOnlyBuffer() in the class java.nio.FloatBuffer. The new buffer cannot have any modifications as it is a read-only buffer. However, the capacity, positions, limits etc. of the new buffer are the same as the previous ... Read More

How to use remove() in android ConcurrentLinkedQueue?

karthikeya Boyini

karthikeya Boyini

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

64 Views

Before getting into an example, we should know what ConcurrentLinkedQueue is, it is an unbounded queue based on linked nodes. Multiple threads can access queue elements with safety. Elements travel based on queue strategy as FIFO and elements going to insert from a tail. It does not allow null values.This ... Read More

Java Program to create a BigDecimal from a string type value

karthikeya Boyini

karthikeya Boyini

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

303 Views

Let us first create a BigDecimal type with string value −BigDecimal one = new BigDecimal("562537627.8787867");Now, create a BigDecimal with long −BigDecimal two = BigDecimal.valueOf(562L);After that use add() with the aug end value i.e. the value in “two” object −one = one.add(two);Example Live Demoimport java.math.BigDecimal; public class Demo {    public static ... Read More

Advertisements