2021年3月5日星期五

Java - How to print dictionary value

I am trying to create a dictionary where it looks like <String, String[]>. However whenever it is not allowing me to get the elements of the array. Am I doing it wrongly?

Dictionary zones = new Hashtable();  String[] countries = {"country1", "country2"};  zones.put("Red", countries);  System.out.println(zones.get("Red")[0]);  

I am guessing that I can't use array for dictionary value? Is there an alternative to this?

https://stackoverflow.com/questions/66501952/java-how-to-print-dictionary-value March 06, 2021 at 11:02AM

没有评论:

发表评论