I have defined clusters variable as shown below in java.
HashMap<double[],String> clusters = new HashMap<double[],String>();
My question is how can I access String values one by one from clusters? Ex. String name=clusters."?";
I have defined clusters variable as shown below in java.
HashMap<double[],String> clusters = new HashMap<double[],String>();
My question is how can I access String values one by one from clusters? Ex. String name=clusters."?";
This is a really bad idea to use arrays as keys in HashMap
, because hashCode()
of array can return different values for array instances with the same content.
You can iterate the values using Map.values()
:
for (String value : clusters.values()) {
// ... whatever.
}