0
Map <String ,List<Edge>> graph = new HashMap<String, List<Edge>>();

this is the map
i filled it with nodes(String) and edges(neighbor(String),weight(int)) ı can print the keys but ı couldnt reach the neighbor and weight variables thanks for the help

public class Edge {

    String Destination;
    int weight;

}

main class just read from txt some data like (node)1.(to)2(50(weight)) in this pattern

Cœur
  • 37,241
  • 25
  • 195
  • 267
Alper Fırat Kaya
  • 2,079
  • 1
  • 18
  • 18
  • what it prints then, when you write `System.out.println(graph.toString());`.??? – ELITE May 16 '15 at 11:43
  • provide your `Edge` class and also willing to know what you tried to print?? – ELITE May 16 '15 at 11:46
  • 8=[Edge@5c647e05, Edge@5c647e05, Edge@5c647e05, Edge@5c647e05, Edge@5c647e05, Edge@5c647e05, Edge@5c64................................................. – Alper Fırat Kaya May 16 '15 at 11:46
  • ok...in that case override method `public String toString()` in class `Edge.java` and return `String` from that method to print variables... – ELITE May 16 '15 at 11:48
  • if so, then close your question by accepting the answer.... – ELITE May 16 '15 at 11:52

1 Answers1

0

add one method in your Edge.java class which will return neighbor and weight variables like this..

public String toString() {
    return "(" + neighbor + " : " + weight + ")";
}

and it will print correct output..

ELITE
  • 5,815
  • 3
  • 19
  • 29