How do we access the method and properties of Math Object in Java?



We can access properties and methods of Math objects by specifying the object name Math followed by a period(.) and then the property or method  name.
Syntax:-
Math.property_name
Math.method(arg1,arg2………ardN)
Example:-
<html>
<head><title>math objects</title></head>
<body>
<script language="Javascript">
document.write("Round of value of 356.7995 = "+Math.round(356.7995)+"<br>");
document.write("Maximum of 34 and 56 = "+Math.max(34,56)+"<br>");
document.write("Minimum of 34 and 56 = "+Math.min(34,56)+"<br>");
document.write("Power of 5 by 3 = "+Math.pow(5,3)+"<br>");
document.write("Absolute value of 245.25 = "+Math.abs(245.25)+"<br>");
document.write("Natural log of 25 = "+Math.log(25)+"<br>");
</script>
</body>
</html>

Comments

Popular posts from this blog

Write a program to add two number using inline function in C++?

Traversing of elements program with algorithm and Flowchart