TimeUnit values() method in Java with Examples
The values() method of TimeUnit Class returns an array containing the constants of this enum type, in the order they are declared. In short, this method is used to get the Enum Constants of TimeUnit Class.
Syntax:
public static TimeUnit[] values()
Return Value: This method returns an array containing the constants of this enum type, in the order they are declared
Below program illustrate the TimeUnit values() method:
import java.util.concurrent.*;
class GFG {
public static void main(String args[])
{
System.out.println( "The Enum constants "
+ "of TimeUnit Class "
+ "using TimeUnit.values() "
+ "are:" );
for (TimeUnit constants : TimeUnit.values()) {
System.out.println(constants);
}
}
}
|
Output:
The Enum constants of TimeUnit Class using TimeUnit.values() are:
NANOSECONDS
MICROSECONDS
MILLISECONDS
SECONDS
MINUTES
HOURS
DAYS
Last Updated :
15 Oct, 2018
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...