Reputation: 3
I can't get my head around this at the moment so any help would be great..
for(EdgeOf e: gra.getEachVertex()) {
System.out.println(e.getId());
}
From this I get a result of 41_1
, 32_2
but I want to split these values up and reuse them. I can't seem to pull these values without getting the them both together..?
How can i string.split
this?
Upvotes: 0
Views: 203
Reputation: 15535
At 1st iteration e.getId() returns 41_1, so u can split it as 41 and 1 by using split("_"), do the same in 2nd iteration also..
for(EdgeOf e: gra.getEachVertex()) {
String str = e.getId();
String[] str2 = str.split("_");
System.out.println(str2[0] + " " + str2[1]);
}
Upvotes: 2
Reputation: 5666
Try use string.split()
:
for(EdgeOf e: gra.getEachVertex()) {
String[] values = e.getId().split("_");
String x = values[0];
String y = values[1];
}
Upvotes: 1