Java Math Class

From Wikiversity
Jump to navigation Jump to search

Note: All functions in class Math are static, meaning you do not have to create an instance of it.

Functions[edit]

Math.abs - Use this with an integer, float, long, or double. It returns the absolute value of what you ask.
Example: "Math.abs(-39)" will return 39


Math.random - No parameter. It returns a double from 0 - 1.
Example: "(int)(Math.random()*100) will return a integer from 0 - 100"
Add more particularly useful..
Go to http://java.sun.com/j2se/1.4.2/docs/api/java/lang/Math.html for more.