We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I've read a few remove() posts on this forum, and while my problem is much more simple, I still can't figure it out. I understand that remove() removes an int, but I think I've tried that. Am I on the right track with:
remove(foundLink); // doesnt work because not an int
or
foundLink.remove(a); // doesnt work, not sure why...
Any help on this matter would be greatly appreciated. A portion of my code below. Thanks!
void searchEndLinks () {
htmlList = new HtmlList(URL_answer);
ArrayList makeLinks= (ArrayList) htmlList.getLinks();
for(int a = 10;a<50;a++){
String temp = makeLinks.get(a).toString();
String [] wikiLinkTemp = split(temp, "url:");
String []wikiLink = trim(wikiLinkTemp);
String foundLink = baseURL + wikiLink[1];
//println("This is wikilink FOUNDLINK " + foundLink);
if( foundLink.contains(valueToRemove) == true) {
println("found a match");
remove(foundLink);
//foundLink.remove(a);
}
// println("this is the size of FoundLINK forFINAL before remove = " + foundLink.length());
finalNodes.add(foundLink);
}
}
Answers
Check this out . I didn't run your code (can't).
No (you cant even put an int in an arrayList, only objects, unless wrapped in an Integer...) remove takes an int as argument, this int is the index of the element to be removed. (There is another flavour of remove which takes an object, let's skip this for now :).
look this sample:
I reformatted your code (with Ctrl+T in the PDE) and added some comments on your coding...
You have to tell which array list you want to remove from: you can have several of them in your sketch!