-1

as below, "n.getNodeData().getAttributes().getValue("sex")" will return a Object value, but how can i match it with String value "male"? so that i can extract out all value in the column who is male?

for (Node n : graphModel.getGraph().getNodes()) {
            if(n.getNodeData().getAttributes().getValue("sex") == "male")
            System.out.println(n.getNodeData().getAttributes().getValue("sex"));
        }
Thomas Hu
  • 45
  • 1
  • 2
  • 9
  • First of all, read [this](http://stackoverflow.com/questions/513832/how-do-i-compare-strings-in-java). Second, implement an appropriate `toString` method and invoke it. – Sotirios Delimanolis Jun 25 '14 at 21:20
  • What type does n.getNodeData().getAttributes().getValue("sex") return? If it returns a String, use the equals method to compare with "male" instead of "==" – Vivin Jun 25 '14 at 22:12

1 Answers1

0
String sex = (String)n.getNodeData().getAttributes().getValue("sex");
    if("male".equals(sex))
user1339772
  • 783
  • 5
  • 19