[Solved] Check if element in for each loop is empty


Based on the fact that your images is a available ArrayList<>, you should do like this:

   if(images.size() > 0){
      for (Element src : images){
          if (src != null) {
             System.out.println("Source " + src.attr("abs:src"));
          }
      }
  } else {
      System.out.println("There are no elements in ArrayList<> images");
  }

First you check if there are elements in the ArrayList. If there are no Elements insite, print it out. if there are elements, you go through the foreach loop and check each elements if it is not null.

2

solved Check if element in for each loop is empty