一、目的
在我们编写Java代码的过程中,Map是我们常用的存储数据的类型,因为他的查询效率非常的高。如果想要遍历Map的话,是使用keySet()方法,是entrySet()方法,是迭代器,是forEach呢?
下面通过实验说明:建议使用entrySet(),最好是forEach.
二、测试过程
下面是测试Map遍历的代码:
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an