Lessons

Java tutorial

Java Math

The Math class provides common calculations. max and min pick one of two numbers, sqrt returns a square root as a double, and abs returns a number without its sign.

Example

Edit the code and run it again. This runner stays in your browser and covers the syntax used in these lessons.

Output

Run the example to see output here.

What this code does

The lines show the larger number, the smaller number, the square root of 49, and the absolute value of -6.