[Go to site: main page, start]

0% found this document useful (0 votes)
6 views6 pages

Java Math.min and Math.max Methods

Uploaded by

neuralhack.io
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views6 pages

Java Math.min and Math.max Methods

Uploaded by

neuralhack.io
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

8/14/25, 9:51 PM Java Math

 Tutorials  Exercises  Services   Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C

Java Math
❮ Previous Next ❯

The Java Math class has many methods that allows you to perform mathematical tasks
on numbers.

[Link](x,y)
The [Link](x,y) method can be used to find the highest value of x and y:

Example Get your own Java Server

[Link](5, 10);

Try it Yourself »

[Link](x,y)
The [Link](x,y) method can be used to find the lowest value of x and y:

Example

[Link] 1/6
8/14/25, 9:51 PM Java Math

[Link](5,
Tutorials  10);
Exercises  Services   Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
Try it Yourself »

[Link](x)
The [Link](x) method returns the square root of x:

Example

[Link](64);

Try it Yourself »

[Link](x)
The [Link](x) method returns the absolute (positive) value of x:

Example

[Link](-4.7);

Try it Yourself »

Random Numbers
[Link]() returns a random number between 0.0 (inclusive), and 1.0 (exclusive):
[Link] 2/6
8/14/25, 9:51 PM Java Math

 Tutorials 
Example Exercises  Services   Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C
[Link]();

Try it Yourself »

To get more control over the random number, for example, if you only want a random
number between 0 and 100, you can use the following formula:

Example

int randomNum = (int)([Link]() * 101); // 0 to 100

Try it Yourself »

Complete Math Reference


For a complete reference of Math methods, go to our Java Math Methods Reference.

?
Exercise
What is the output of the following code?
[Link](5, 10);

15

10

50

[Link] 3/6
8/14/25, 9:51 PM Java Math

 Tutorials  Exercises  Services 


Submit Answer »
 Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C

❮ Previous Next ❯

Track your progress - it's free! Sign Up Log in

COLOR PICKER

 

[Link] 4/6
8/14/25, 9:51 PM Java Math

 Tutorials  Exercises  Services   Sign In

HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C

 PLUS SPACES

GET CERTIFIED FOR TEACHERS

FOR BUSINESS CONTACT US

Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
[Link] Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial

Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
[Link] Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
Angular Reference
jQuery Reference

Top Examples Get Certified


HTML Examples HTML Certificate
CSS Examples CSS Certificate
JavaScript Examples JavaScript Certificate
How To Examples Front End Certificate
SQL Examples SQL Certificate
Python Examples Python Certificate
[Link] Examples PHP Certificate
Bootstrap Examples jQuery Certificate
[Link] 5/6
8/14/25, 9:51 PM Java Math
PHP Examples Java Certificate

 Tutorials  Java Examples


Exercises 
XML Examples
Services   C++ Certificate
C# Certificate
Sign In
jQuery Examples XML Certificate
HTML
 CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO [Link] C

    

FORUM ABOUT ACADEMY


W3Schools is optimized for learning and training. Examples might be simplified to improve reading and
learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full
correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie
and privacy policy.

Copyright 1999-2025 by Refsnes Data. All Rights Reserved. W3Schools is Powered by [Link].

[Link] 6/6

You might also like