Answer the question
In order to leave comments, you need to log in
How to remove all elements and not just the first Java?
Hello!
I am a complete newbie to Java. Help me please!
There is a code, it removes all selected items
var campaignIterator = AdWordsApp.campaigns()
.get();
if (campaignIterator.hasNext()) {
var campaign = campaignIterator.next();
var locationIterator = campaign.targeting().targetedLocations().get();
while (locationIterator.hasNext()) {
var loc = locationIterator.next();
loc.remove();
}
}
var campaignMobileAppIterator = campaign.extensions().mobileApps().get();
var campaignMobileApp = campaignMobileAppIterator.next();
campaign.removeMobileApp(campaignMobileApp);
Answer the question
In order to leave comments, you need to log in
Good afternoon.
Well hasNext() returns boolean if there is a next element. next() gets the next element.
Accordingly, as in the first example, you first check if there is a next element, and then get it and delete it. Roughly speaking, you need to iterate over the campaignIterator and then remove each element
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question