George John has Published 1167 Articles

Remove all cancelled tasks from the timer's task queue in Java

George John

George John

Updated on 26-Jun-2020 09:46:03

267 Views

One of the methods of the Timer class is the int purge() method. The purge() method removes all the canceled tasks from the timer’s task queue. Invoking this method does not affect the behavior of the timer, rather it eliminates references to the canceled tasks from the queue. The purge() ... Read More

Cancel the Timer Task in Java

George John

George John

Updated on 26-Jun-2020 09:32:11

5K+ Views

In order to cancel the Timer Task in Java, we use the java.util.TimerTask.cancel() method. The cancel() method returns a boolean value, either true or false. The cancel() method is used to cancel the timer task.Declaration −The java.util.TimerTask.cancel() method is declared as follows −public boolean cancel()The cancel() methods returns true when ... Read More

Compute the elapsed time of an operation in Java

George John

George John

Updated on 26-Jun-2020 09:28:08

165 Views

To compute the elapsed time of an operation in Java, we use the System.currentTimeMillis() method. The java.lang.System.currentTimeMillis() returns the current time in milliseconds.Declaration −The java.lang.System.currentTimeMillis() is declared as follows −public static long currentTimeMillis()The method returns time difference in milliseconds between the current time and midnight, January 1, 1970 (UTC or ... Read More

Get the IDs according to the given time zone offset in Java

George John

George John

Updated on 26-Jun-2020 09:14:08

179 Views

In order to get the IDs according to the given time zone offset in Java, we use the getAvailableIDs(int rawOffset) method. The java.util.TimeZone.getAvailableIDs(int rawOffset) method returns the available IDs according to the given time zone offset in the arguments.Declaration − The java.util.TimeZone.getAvailableIDs(int rawOffset) method is declared as follows −public static ... Read More

Substitute tokens in a String in Java

George John

George John

Updated on 26-Jun-2020 09:10:28

785 Views

To substitute tokens in a String in Java, we use the Message Format class. The Message Format class provides a means to produce concatenated messages which are not dependent on the language. The Message Format class extends the Serializable and Cloneable interfaces.Declaration − The java.text.MessageFormat class is declared as follows ... Read More

Bounce In Down Animation Effect with CSS

George John

George John

Updated on 26-Jun-2020 08:15:14

183 Views

To implement Bounce In Down Animation Effect with CSS, you can try to run the following code −ExampleLive Demo                    .animated {             background-image: url(/css/images/logo.png);             background-repeat: no-repeat;     ... Read More

Fibonacci of large number in java

George John

George John

Updated on 26-Jun-2020 07:39:23

514 Views

Fibonacci numbers of Fibonacci series grows exponentially and can be very large for large numbers like 500 or 1000. To handle such number, long data type is not sufficient. BigInteger can handle large number easily. BigInteger is useful in scenarios where calculations results in data which is out of limit ... Read More

Compare two Strings lexicographically in Java programming

George John

George John

Updated on 26-Jun-2020 07:30:58

274 Views

We can compare two strings lexicographically using following ways in Java.Using String.compareTo(String) method. It compares in case sensitive manner.Using String.compareToIgnoreCase(String) method. It compares in case insensitive manner.Using String.compareTo(Object) method. It compares in case sensitive manner.These methods returns the ascii difference of first odd characters of compared strings.Example Live Demopublic class Tester ... Read More

How to create the immutable class in Java?

George John

George John

Updated on 26-Jun-2020 07:27:35

224 Views

An immutable class object's properties cannot be modified after initialization. For example String is an immutable class in Java. We can create a immutable class by following the given rules below.Make class final − class should be final so that it cannot be extended.Make each field final − Each field ... Read More

Difference between TreeMap, HashMap and LinkedHashMap in Java programming

George John

George John

Updated on 26-Jun-2020 07:25:35

505 Views

HashMap, TreeMap and LinkedHashMap all implements java.util.Map interface and following are their characteristics.HashMapHashMap has complexity of O(1) for insertion and lookup.HashMap allows one null key and multiple null values.HashMap does not maintain any order.TreeMapTreeMap has complexity of O(logN) for insertion and lookup.TreeMap does not allow null key but allow multiple ... Read More

Advertisements