Retrieve instance of class or object Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Retrieve instance of class or object without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I am having trouble understanding how to get certain instances of an object or class. Sorry for the newb question. I have a class called waypoint which contains some basic info about the waypoint, next im grabbing a list of the user’s favorited waypoints from a server, then i check to see if the list of favorited waypoints from the server matches the list of favorited waypoints on the local device if it doesnt then i need to make them match and when trying to remove a instance of the waypoint I dont know how to remove the actual instance of it. My code is below:

public class Waypoint
  public long id;
  public String name;
  public Bitmap bitmap;
  public boolean deleted;
  public int waypoint_type;
  public int waypoint_id;

  public Waypoint(long id, String name, Bitmap bitmap, int waypoint_type, int waypoint_id)
  { = id; = name;
    this.bitmap = bitmap;
    this.waypoint_type = waypoint_type;
    this.waypoint_id = waypoint_id;
  public long getId() {
  return id;

public ArrayList<Waypoint> mWaypoint = new ArrayList<>();
mWaypoint .add(new Waypoint(getNewId(), name, BitmapFactory.decodeResource(getResources(), R.drawable.stoplogo_small), stopTypeInteger, idInteger));

//attempt to remove it from my live list view
int pos = mAdapterWaypoint.getPosition(WaypointObjectGoesHere); //I dont know how to get this instance that I need here.
mAdapterWaypoint.remove(WaypointObjectGoesHere); //I dont know how to get this instance that I need here.


An Iterator may be your friend here:

    Iterator<Waypoint> iterator = mWaypoint.iterator();
    Waypoint waypoint;
    while (iterator.hasNext()) {
        waypoint =;
        if (waypoint.getId() == 1) { // 1 is an example
We are here to answer your question about Retrieve instance of class or object - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji