编程第八十八天

Array转化为map

2
3
4
5
6
7
8
9
10
11
12
13
14
15
import java.util.Map;
import org.apache.commons.lang.ArrayUtils;
   
public class Main {
   
 public static void main(String[] args) {
  String[][] countries = { { "United States", "New York" }, { "United Kingdom", "London" },
    { "Netherland", "Amsterdam" }, { "Japan", "Tokyo" }, { "France", "Paris" } };
   
  Map countryCapitals = ArrayUtils.toMap(countries);
   
  System.out.println("Capital of Japan is " + countryCapitals.get("Japan"));
  System.out.println("Capital of France is " + countryCapitals.get("France"));
 }
}

猜你喜欢

转载自blog.csdn.net/imezreal/article/details/72843950