Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

decimals java

// Java Program to Round a Number to n Decimal Places
// using format() Method
 
// Importing required classes
import java.io.*;
 
// Main class
class GFG {
 
    // Main driver method
    public static void main(String[] args)
    {
        // Declaring and initializing a double number
        double number = 3.141341435;
 
        // Rounding number to 2 decimal places
        // using format method
        System.out.format("%.2f", number);
    }
}
Source by www.geeksforgeeks.org #
 
PREVIOUS NEXT
Tagged: #decimals #java
ADD COMMENT
Topic
Name
7+9 =