I read that .equals() compares the value(s) of objects whereas == compares the references (that is -- the memory location pointed to by the variable). See here: What is the difference between == vs equals() in Java?
But observe the following piece of code:
package main;
public class Playground {
    public static void main(String[] args) {
        Vertex v1 = new Vertex(1);
        Vertex v2 = new Vertex(1);
        if(v1==v2){
            System.out.println("1");
        }
        if(v1.equals(v2)){
            System.out.println("2");
        }
    }
}
class Vertex{
    public int id;
    public Vertex(int id){
        this.id = id;
    }
}
Output:
(Nothing)
Shouldn't it be printing 2?