The getMaximumFractionDigits() method is a built-in method of the java.text.DecimalFomrat class in Java and is used to get the maximum number of digits allowed in the fractional or the decimal part of a Number.
Syntax:
public int getMaximumFractionDigits()
Parameters: The function does not accepts any parameter.
Return Value: The function returns the maximum number of digits allowed in the decimal part of a number.
Below is the implementation of the above function:
Program 1:
import java.text.DecimalFormat;
import java.util.Currency;
import java.util.Locale;
public class Main {
public static void main(String[] args)
{
DecimalFormat deciFormat = new DecimalFormat();
System.out.println(deciFormat.getMaximumFractionDigits());
}
}
|
Program 2:
import java.text.DecimalFormat;
import java.util.Currency;
import java.util.Locale;
public class Main {
public static void main(String[] args)
{
DecimalFormat deciFormat = new DecimalFormat();
deciFormat.applyPattern( "##.##" );
System.out.println(deciFormat.getMaximumFractionDigits());
}
}
|
Reference: https://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html#getMaximumFractionDigits()
Feeling lost in the vast world of Backend Development? It's time for a change! Join our
Java Backend Development - Live Course and embark on an exciting journey to master backend development efficiently and on schedule.
What We Offer:
- Comprehensive Course
- Expert Guidance for Efficient Learning
- Hands-on Experience with Real-world Projects
- Proven Track Record with 100,000+ Successful Geeks
Last Updated :
01 Apr, 2019
Like Article
Save Article