code: public static void runExample(
        AdWordsServicesInterface adWordsServices, AdWordsSession session, Long campaignId)
        throws RemoteException {
      // Get the AdGroupService.
      AdGroupServiceInterface adGroupService =
          adWordsServices.get(session, AdGroupServiceInterface.class);
  
      int offset = 0;
      boolean morePages = true;
  
      // Create selector.
      SelectorBuilder builder = new SelectorBuilder();
      Selector selector = builder
          .fields(AdGroupField.Id, AdGroupField.Name)
          .orderAscBy(AdGroupField.Name)
          .offset(offset)
          .limit(PAGE_SIZE)
          .equals(AdGroupField.CampaignId, campaignId.toString())
          .build();
  
      while (morePages) {
        // Get all ad groups.
        AdGroupPage page = adGroupService.get(selector);
  
        // Display ad groups.
        if (page.getEntries() != null) {
          for (AdGroup adGroup : page.getEntries()) {
            System.out.printf("Ad group with name '%s' and ID %d was found.%n", adGroup.getName(),
                adGroup.getId());
          }
        } else {
          System.out.println("No ad groups were found.");
        }
  
        offset += PAGE_SIZE;
        selector = builder.increaseOffsetBy(PAGE_SIZE).build();
        morePages = offset < page.getTotalNumEntries();
      }
    }
docs: Runs the example.
  
  @param adWordsServices the services factory.
  @param session the session.
  @param campaignId the ID of the campaign to use to find ad groups.
  @throws ApiException if the API request failed with one or more service errors.
  @throws RemoteException if the API request failed due to other errors.