title: I read in a book that if you pass an array of size 0 as an argument to the function of Functional Interface then it will throw
body: <p>I read in a book that if you pass an array of size 0 as an argument to the function of Functional Interface then it will result in a checked exception and compiler will issue an warning.So you have to create an user defined exception and throw it the abstract function definition in the functional interface for the code to run properly.
  I tried to run this code and its working fine:</p>
  
  <pre><code>@FunctionalInterface
  interface DoubleArray{
      double func(int[] n);
  }
      public class GenDemo {
  
          public static void main(String[] args) {
              DoubleArray ref=(n)-&gt;{
                  double avg=0;
                  for(int i=0;i&lt;n.length;i++)
                      avg=avg+n[i];
                  avg=avg/n.length;
                  return avg;
                  };
  
                  int arr[]={1,2,3,4,5};
                  System.out.println(ref.func(arr));
                  System.out.println(ref.func(new int[0]));
            }
  }
  </code></pre>
  
  <p>Output:
  3.0
  NaN</p>
  
  <p>What is this "NaN" ?</p>
  
  <p>What book expects is something like this:</p>
  
  <pre><code>@FunctionalInterface
  interface DoubleArray{
      double func(int[] n)throws EmptyArrayException;
  }
  class EmptyArrayException extends Exception{
      EmptyArrayException(){
      super("Empty Array passed");
      }
  }
  public class GenDemo {
  
      public static void main(String[] args) {
          DoubleArray ref=(n)-&gt;{
              double avg=0;
              if(n.length==0)
                  throw new EmptyArrayException();
              for(int i=0;i&lt;n.length;i++)
                  avg=avg+n[i];
              avg=avg/n.length;
              return avg;
              };
  
              int arr[]={1,2,3,4,5};
              System.out.println(ref.func(new int[0]));
          }
  } 
  </code></pre>
  
  <p>But even without doing this the code is working fine.
  As per my understanding checked exceptions are the exception that compiler checks for before compilation and it will give compile time error.
  So above written doesn't throws any checked exception it executes smoothly. Then what is the point to throw a user defined exception for null array ref.
  Documentation says that if a lambda exp throws a checked exception then that exception must be compatible with the exception(s) listed in the throws clause of the abstract method in the functional interface.</p>
  
  <p>Any answers please?
  Thanks.</p>