Ankith Reddy has Published 1070 Articles

Get square root of a number using Math.sqrt in Java

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 10:00:56

1K+ Views

In order to get the square root of a number in Java, we use the java.lang.Math.pow() method. The Math.pow(double a) method accepts one argument of the double data type and returns a value which is the square root of the argument.Declaration − The java.lang.Math.sqrt() method is declared as follows −public ... Read More

Get the base 10 logarithm of a value in Java

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 09:57:36

949 Views

To get the base 10 logarithm of value in Java, we use the java.lang.Math.log10() method. This method returns the log of value to the base 10 in the form of a double. If a number is 10n, then the result is n. If the value passed is NaN or negative, ... Read More

Terminate the timer in Java

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 09:47:44

1K+ Views

One of the methods of the Timer class is the cancel() method. It is used to terminate the current timer and get rid of any presently scheduled tasks.The java.util.Timer.cancel() method is declared as follows −public void cancel()Let us see a program which uses the cancel() methodExample Live Demoimport java.util.*; public class ... Read More

Schedule a task for repeated fixed delay execution in Java

Ankith Reddy

Ankith Reddy

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

872 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

11K+ 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

210 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

59 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

964 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

CSS background-size property

Ankith Reddy

Ankith Reddy

Updated on 26-Jun-2020 08:00:36

158 Views

The CSS background-size property is used to specify size of the background images.ExampleYou can try to run the following code to implement the background-size property in CSS:Live Demo                    #demo {             border: 5px dashed ... Read More

Does JVM creates object of Main class in Java?

Ankith Reddy

Ankith Reddy

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

388 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

Advertisements