As stated above, using:
RS2Object temp = objects.closest("Name here");
GroundItem i = grounditems.closest("Name here");
NPC n = npcs.closest("Name here");
It is definitely worth jumping into the API and familiarizing yourself with it, also make sure you import the correct objects and not the legacy ones ^_^