Home Segments Top Top Previous Next

160: Sidetrip

Java offers two useful built-in final class variables for the Math class. The following illustrates:

public class Demonstrate { 
 // First, define displayMovieRating with integers: 
 public static void main (String argv[]) { 
  System.out.println("Value of pi: " + Math.PI);  
  System.out.println("Value of e:  " + Math.E);  
 } 
} 
--- Result --- 
Value of pi: 3.141592653589793 
Value of e:  2.718281828459045