Math.abs(x)
method returns the absolute (positive) value of x
:
System.out.println( Math.abs( 3.0-16.0 ) ); // Output: 13.0 |
Math.random( )
returns a random number between 0 (inclusive), and 1 (exclusive):
// Returns an integer between 0 and 99, inclusively. System.out.println( (int) ( Math.random( ) * 100 ) ); |
|