Karthikeya Boyini has Published 2193 Articles

How to use pool() ArrayBlockingQueue in android?

karthikeya Boyini

karthikeya Boyini

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

153 Views

Before getting into an example, we should know what arrayblockingqueue is, it travels FIFO manner and the first element going to live the longest period of time and last element of the queue going to live a short period of the time.This example demonstrates about How to use pool() ArrayBlockingQueue ... Read More

Make a Hashtable read-only in Java

karthikeya Boyini

karthikeya Boyini

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

225 Views

Read-only Hashtable would mean users won’t be able to add or remove elements from it. Let us first create a Hashtable with key-value pair −Hashtablehash = new Hashtable(); hash.put("1", "A"); hash.put("2", "B"); hash.put("3", "C"); hash.put("4", "D"); hash.put("5", "E"); hash.put("6", "F"); hash.put("7", "G");Now, use unmodifiableMap() to form a Hashtable read-only −Mapm ... Read More

Get total in the last row of MySQL result?

karthikeya Boyini

karthikeya Boyini

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

673 Views

To get total in the last row of MySQL result, use the following syntax −(    SELECT yourColumnName1,    yourColumnName2,    yourColumnName3,    .    .    N    FROM yourTableName ) UNION (    SELECT "yourMessage" AS anyAliasName1,    SUM(yourColumnName1) AS anyAliasName2,    SUM(yourColumnName2) AS anyAliasName3,    .   ... Read More

How to use pop() in android ConcurrentLinkedDeque?

karthikeya Boyini

karthikeya Boyini

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

134 Views

Before getting into an example, we should know what ConcurrentLinkedDeque is, it is unbounded deque based on linked nodes. Multiple threads can access deque elements with safety.This example demonstrates about How to use pop() in android ConcurrentLinkedDequeStep 1 − Create a new project in Android Studio, go to File ⇒ ... Read More

Java Program to get the reverse of the NavigableSet

karthikeya Boyini

karthikeya Boyini

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

115 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

798 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

125 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

350 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

112 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

112 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

Advertisements