Ankith Reddy has Published 996 Articles

Schedule a task for repeated fixed delay execution in Java

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 09:34:27

1K+ Views

In fixed-delay execution, each execution is scheduled with respect to the original execution time of the preceding execution. If an execution is delayed for a particular reason (case in point, garbage collection), the subsequent executions will be delayed as well.There are two ways in which a task can be scheduled ... Read More

Compute elapsed time in seconds in Java

Ankith Reddy

Ankith Reddy

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

13K+ Views

To compute the elapsed time of an operation in seconds 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 ... Read More

Get elapsed time in days in Java

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 09:22:48

332 Views

To get the elapsed time of an operation in days 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 ... Read More

Create a copy of a TimeZone object in Java

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 09:17:25

97 Views

In order to get a copy of a TimeZone object in Java, we use the clone() method. The clone() method creates of a copy of the TimeZone.Declaration −The java.util.TimeZone.clone() method is declared as follows −public Object clone()Let us see a Java program which creates a copy of the TimeZone object ... Read More

Set the base time zone offset to GMT in Java

Ankith Reddy

Ankith Reddy

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

1K+ Views

In order to set the base time zone to GMT in Java, we use the setRawOffset(int offsetMillis) method. The java.util.TimeZone.setRawOffset(int offsetMillis) method set the base timezone offset to GMT.Declaration − The java.util.TimeZone.setRawOffset(int offsetMillis) method is declared as follows −public abstract void setRawOffset(int offsetMillis)where offsetMillis is the given base time zone ... Read More

Does JVM creates object of Main class in Java?

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 07:40:55

525 Views

As we know that Java needs main() method to be static in the public class to make it executable. The prime reason for this requirement is to make JVM enable to call the main() method without creating an object. That simply means that JVM does not create the object of ... Read More

Find max and min values in array of primitives using Java

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 07:37:59

696 Views

This example shows how to search the minimum and maximum element in an array by using Collection.max() and Collection.min() methods of Collection class.Example Live Demoimport java.util.Arrays; import java.util.Collections; public class Main {    public static void main(String[] args) {       Integer[] numbers = { 8, 2, 7, 1, 4, ... Read More

CopyOnWriteArrayList Class in Java programming

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 07:29:45

255 Views

Class declarationpublic class CopyOnWriteArrayList extends Object implements List, RandomAccess, Cloneable, SerializableCopyOnWriteArrayList is a thread-safe variant of Arraylist where operations which can change the arraylist (add, update, set methods) creates a clone of the underlying array.CopyOnWriteArrayList is to be used in Thread based environment where read operations are very frequent and ... Read More

How to Convert Hexadecimal to Decimal?

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 06:29:13

17K+ Views

Whereas Hexadecimal number is one of the number systems which has value is 16 and it has only 16 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and A, B, C, D, E, F. Where A, B, C, D, E and F are single bit representations of ... Read More

Octal Number System

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 06:25:16

14K+ Views

Octal Number System is one the type of Number Representation techniques, in which there value of base is 8. That means there are only 8 symbols or possible digit values, there are 0, 1, 2, 3, 4, 5, 6, 7. It requires only 3 bits to represent value of any ... Read More

Advertisements