I want to add instances of a class to an arraylist.and here is the code:
ArrayList<Edge> edges = new ArrayList<Edge>(); //A List Containing All the Edges & their startNode,endNode
System.out.println("Enter Number of Nodes: ");
int noOfNodes = scan.nextInt();  //Gets Number of Nodes in Graph
int graphmatrix[][] = new int[noOfNodes][noOfNodes];  //Makes a Matrix According to Graph
for ( int i=0; i < noOfNodes; i++ ) {
    for (int j=0; j < noOfNodes; j++) {
        if ( j > i ) {
            System.out.println("Enter Relation Between " + i + " & " + j + ": ");
            int length = scan.nextInt();
            graphmatrix[i][j] = length;
            graphmatrix[j][i] = length;
            Edge edge = new Edge(i, j, length);
            edges.add(edge);
        }
    }       
}
System.out.println(edges);
and here is the output of last line:
[dijkstra.Edge@49e4cb85, dijkstra.Edge@2133c8f8, dijkstra.Edge@43a25848]
as you can see,the problem seems to be that it doesn't creates the arraylist. I don't understand what is wrong. and also here is the constructor of Edge class:
public Edge(int startNode, int endNode, int length) {
    this.startNode = startNode;
    this.endNode = endNode;
    this.length = length;
}
