import java.util.Map;
import java.util.HashMap;
import java.util.Collection;
public class Main
{
public static void main(String[] args) {
Map<String, String> map = new HashMap<String, String>();
map.put("Str1", "value1");
map.put("Str2", "value2");
map.put("Str3", "value3");
map.put("Str4", "value4");
map.put("Str5", "value5");
System.out.println(map.entrySet());
Collection<String> values = map.values();
String[] arr = values.toArray(new String[0]);
System.out.println(arr[3]);
}
}
I know Hashmap has no order but this code keeps showing [Str5=value5, Str4=value4, Str3=value3, Str2=value2, Str1=value1] value2 Is there anything that I'm missing?