Java 为什么不能';t直接访问hashmap静态变量

Java 为什么不能';t直接访问hashmap静态变量,java,Java,当我研究HashMap源代码时,我发现HashMap类有很多静态变量,sush为: public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable, Serializable { /** * The default initial capacity - MUST be a power of two. */ static fin

当我研究HashMap源代码时,我发现HashMap类有很多静态变量,sush为:

public class HashMap<K,V>
extends AbstractMap<K,V>
implements Map<K,V>, Cloneable, Serializable
{
    /**
     * The default initial capacity - MUST be a power of two.
     */
    static final int DEFAULT_INITIAL_CAPACITY = 16;

    /**
     * The maximum capacity, used if a higher value is implicitly specified
     * by either of the constructors with arguments.
     * MUST be a power of two <= 1<<30.
     */
    static final int MAXIMUM_CAPACITY = 1 << 30;

    /**
     * The load factor used when none specified in constructor.
     **/
    static final float DEFAULT_LOAD_FACTOR = 0.75f;
公共类HashMap
扩展抽象地图
实现映射、可克隆、可序列化
{
/**
*默认初始容量-必须是2的幂。
*/
静态最终int默认值初始容量=16;
/**
*如果隐式指定了更高的值,则使用最大容量
*由具有参数的构造函数之一执行。

*必须是二次幂,因为它们的访问级别是package,这意味着只有来自同一个包的类才能访问它们。它们不是供公共使用的。您可以阅读有关成员访问规则的详细信息。

它们是包私有的,这意味着只有当您的类位于具有sam的包中时,才可以直接访问它们e名字

声明没有访问修饰符的字段(例如
public
private
protected
)会使其包私有


然而,正如一些人所指出的,在这种特殊情况下,您不需要关心字段(也许除非您为自己的实现扩展了
HashMap

因为它们不是公共的?这些不是变量,它们是常量。