George John has Published 1081 Articles

Get the maximum of two numbers using Math.max in Java

George John

George John

Updated on 26-Jun-2020 10:03:08

1K+ Views

To obtain the maximum of two numbers using Math.max in Java, we use the java.lang.Math.max() method. The Math.max() accepts two numbers and returns the greater of the two. The result is closer to positive infinity on the number line. Even if one of the values is not a number(NaN), the ... Read More

Round float and double numbers in Java

George John

George John

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

9K+ Views

In order to round float and double numbers in Java, we use the java.lang.Math.round() method. The method accepts either double or float values and returns an integer value. It returns the closest integer to number. This is computed by adding ½ to the number and then flooring it.Declaration - The ... Read More

Check if the String contains only unicode letters or digits in Java

George John

George John

Updated on 26-Jun-2020 09:56:58

7K+ Views

To check whether a String contains only unicode letters or digits in Java, we use the isLetterOrDigit() method and charAt() method with decision-making statements.The isLetterOrDigit(char ch) method determines whether the specific character (Unicode ch) is either a letter or a digit. It returns a boolean value, either true or false.Declaration ... Read More

Get the arc tangent of a given value in Java

George John

George John

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

144 Views

To get the arc tangent of a given value in Java, we use the java.lang.Math.atan() method. The atan() method accepts a double value whose angle needs to be computed. The range of the angle returned lies in the range -pi/2 to pi/2. If the argument is NaN, then the result ... Read More

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

George John

George John

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

347 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

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

250 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

239 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

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

Advertisements