java 方法 示例
集合类emptyMap()方法 (Collections Class emptyMap() method)
emptyMap() method is available in java.util package.
emptyMap()方法在java.util包中可用。
emptyMap() method is used to return the immutable empty Map.
emptyMap()方法用于返回不可变的空Map。
emptyMap() method is a static method, so it is accessible with the class name and if we try to access the method with the class object then also we will not get an error.
emptyMap()方法是一个静态方法,因此可以使用类名进行访问,并且如果我们尝试使用类对象访问该方法,那么我们也不会收到错误。
emptyMap() method does not throw an exception at the time of returning an empty immutable map.
返回空的不可变映射时, emptyMap()方法不会引发异常。
Syntax:
句法:
public static final Map emptyMap();
Parameter(s):
参数:
It does not accept any parameter.
它不接受任何参数。
Return value:
返回值:
The return type of this method is Map, it returns an immutable empty map.
此方法的返回类型为Map ,它返回一个不变的空映射。
Example:
例:
// Java program is to demonstrate the example
// of Map emptyMap() of Collections
import java.util.*;
public class EmptyMap {
public static void main(String args[]) {
// By using emptyMap() method is
// to get a empty map
Map map = Collections.emptyMap();
// Display Empty map
System.out.println("map: " + map);
}
}
Output
输出量
map: {}
翻译自: https://www.includehelp.com/java/collections-emptymap-method-with-example.aspx
java 方法 示例