Sunday, November 23, 2025
HomeLanguagesJavaValueRange isFixed() method in Java with Examples

ValueRange isFixed() method in Java with Examples

The isFixed() method of ValueRange class is used to check the value range is fixed and fully known or not.For example, the ChronoField day-of-month runs from 1 to between 28 and 31. The maximum value of day-of-month is not fixed, there is uncertainty about it. However, for the month of December, the range is always 1 to 31, thus it is fixed.

Syntax:

public boolean isFixed()

Parameters: This method accepts nothing.

Return value: This method returns true if the set of values is fixed.

Below programs illustrate the ValueRange.isFixed() method:
Program 1:




// Java program to demonstrate
// ValueRange.isFixed() method
  
import java.time.LocalDateTime;
import java.time.temporal.ChronoField;
import java.time.temporal.ValueRange;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // create LocalDateTime
        LocalDateTime l1
            = LocalDateTime
                  .parse("2018-12-06T19:21:12");
  
        // Get ValueRange object
        ValueRange vR
            = l1.range(ChronoField.DAY_OF_MONTH);
  
        // apply isFixed()
        boolean response = vR.isFixed();
  
        // print results
        System.out.println("isFixed: "
                           + response);
    }
}


Output:

isFixed: true

Program 2:




// Java program to demonstrate
// ValueRange.isFixed() method
  
import java.time.temporal.ValueRange;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // create ValueRange object
        ValueRange vRange = ValueRange.of(1111, 66666);
  
        // apply isFixed()
        boolean response = vRange.isFixed();
  
        // print results
        System.out.println("isFixed: "
                           + response);
    }
}


Output:

isFixed: true

References: https://docs.oracle.com/javase/10/docs/api/java/time/temporal/ValueRange.html#isFixed()

Dominic
Dominichttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Dominic
32407 POSTS0 COMMENTS
Milvus
97 POSTS0 COMMENTS
Nango Kala
6785 POSTS0 COMMENTS
Nicole Veronica
11932 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12000 POSTS0 COMMENTS
Shaida Kate Naidoo
6907 POSTS0 COMMENTS
Ted Musemwa
7168 POSTS0 COMMENTS
Thapelo Manthata
6864 POSTS0 COMMENTS
Umr Jansen
6852 POSTS0 COMMENTS