bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/Java/Java Reference
Java•Java Reference

Java Math round() Method

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind Java Math round() Method?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___.out.println(Math.round(0.60));
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The round() method rounds a number to the nearest integer.
Definition and Usage
Java Math round() Method

❮ Math Methods

Example

System.out.println(Math.round(0.60));
System.out.println(Math.round(0.40));
System.out.println(Math.round(5));
System.out.println(Math.round(5.1));
System.out.println(Math.round(-5.1));
System.out.println(Math.round(-5.9));

Definition and Usage

The round() method rounds a number to the nearest integer.

One of the following

public static long round(double
number )
public static int round(float
number )

Parameter Values

ParameterDescription
numberRequired. A number to round.

Technical Details

Returns:A long value (if the argument is double) or int (if the argument is float) value representing the nearest integer to a number.
Java version:Any

Previous

Java Math rint() Method

Next

Java Math scalb() Method