有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

“同义词”在Java中是什么意思?

我阅读了来自http://docs.oracle.com/javase/8/docs/api/的JavaAPI文档。对于日历类,有以下段落:

DAY_OF_MONTH

public static final int DAY_OF_MONTH

Field number for get and set indicating the day of the month. This is a synonym for DATE. The first day of the month has value 1.

See Also:

DATE, Constant Field Values

我几乎听不懂描述,尤其是被“同义词”这个词弄糊涂了。如果有人能向我解释这段话,我将不胜感激


共 (2) 个答案

  1. # 1 楼答案

    同义词的意思是有相同的意思

    Calendar的源代码中:

    /**
     * Field number for <code>get</code> and <code>set</code> indicating the
     * day of the month. This is a synonym for <code>DAY_OF_MONTH</code>.
     * The first day of the month has value 1.
     *
     * @see #DAY_OF_MONTH
     */
    public final static int DATE = 5;
    
    /**
     * Field number for <code>get</code> and <code>set</code> indicating the
     * day of the month. This is a synonym for <code>DATE</code>.
     * The first day of the month has value 1.
     *
     * @see #DATE
     */
    public final static int DAY_OF_MONTH = 5;
    

    这里两个值都是5,所以都是相同的

  2. # 2 楼答案

    A synonym is

    synonym noun. 1. a word having the same or nearly the same meaning as another in the language, as happy, joyful, elated. A dictionary of synonyms and antonyms (or opposites). 2. (...)

    因此,它意味着某物有一个不同的(字段)名称来表示同一事物

    因此,文档指定如果调用Calendar.DAY_OF_MONTHCalendar.DATE。您将始终获得相同的值

    我们可以在查看documentation for ^{}时验证这一点:

    static int DATE

    Field number for get and set indicating the day of the month.

    static int DAY_OF_MONTH

    Field number for get and set indicating the day of the month.

    两个场的文档完全相同