Friday 7 March 2014

values : Return all TimeUnit constants

public static TimeUnit[] values()
Returns an array containing the constants of this enum type, in the order they are declared.

import java.util.concurrent.TimeUnit;
public class TimeUnitEx {
 public static void main(String args[]){
  TimeUnit[] t;
  t = TimeUnit.values();
  System.out.println("The constants defined in TimeUnit Class are");
  for(int i=0; i<t.length; i++)
   System.out.println(t[i]);
 }
}

Output
The constants defined in TimeUnit Class are
NANOSECONDS
MICROSECONDS
MILLISECONDS
SECONDS
MINUTES
HOURS
DAYS

Related Posts




TimeUnit Class                                                 Get value of Time constant                                                 Home

No comments:

Post a Comment