<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">public class ManyIntervals {

  public static void main(String[] args) {
 
    int n= 4; //number of Intervals to create
    int H= 5; //highest value for base, range
    int L= 1; //lowest value for base, range
  
    //Set of Intervals 
    Interval[] set= new Interval[n];
    for (int i=0; i&lt;set.length; i++) {
      set[i]= new Interval(
                    Math.floor(Math.random()*(H-L+1)+L),
                    Math.floor(Math.random()*(H-L+1)+L));
      System.out.println(set[i]);
    }
    
    //Find Interval with highest endpoint
    Interval hi= set[0];  //Interval with highest endpoint
                          //so far
    for (int i=1; i&lt;set.length; i++)
      if (set[i].getEnd()&gt;hi.getEnd())
        hi= set[i];
    System.out.println("Interval with highest endpoint: " + hi);
 
    //Find 1st Interval with endpoint 6
    int target= 6;
    int i= 0;
    while (i&lt;set.length &amp;&amp; set[i].getEnd()!=target)
      i++;
    if (i&lt;set.length)
      System.out.println("First interval with endpoint 6: " + set[i]);
    else
      System.out.println("No interval with endpoint 6");
  }
 
}</pre></body></html>