Stephan van Hulst wrote:
Why are you using such a method anyway? Why not provide a constructor that takes an array?
Stephan van Hulst wrote:Because you are redeclaring the type parameter E in your method.
So you could have Graph's toString() which calls Node's toString() which calls it's data's toString(), with each layer adding whatever structural stuff it knows about/is responsible for (commas, brackets, etc.).
Jeff Verdegan wrote:
Gil Shoam wrote:Fast reply
Not exactly, that was just a test to see if I can access the char from graph._nodes.
What I want is to write a String representation of the graph inc the nodes and edges.
Then your Graph class needs to override toString() to pring out the nodes and edges how you want. And if you have classes for Node and/or Edge, they need to override toString to display themselves appropriately.