"synonym"在Java中是什么意思?
What does "synonym" mean in Java?
我阅读了 JAVA API 来自 http://docs.oracle.com/javase/8/docs/api/ 的文档。对于日历class,有以下段落:
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
描述的有点看不懂,尤其是被“同义词”这个词搞糊涂了。如果有人能给我解释一下这段话,我将不胜感激。
一个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_MONTH
或 Calendar.DATE
。您将始终获得相同的值。
我们可以通过查看 documentation for Calendar
:
来验证这一点
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.
两个字段的文档完全相同。
同义词表示具有相同的含义。
在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,所以都是一样的
我阅读了 JAVA API 来自 http://docs.oracle.com/javase/8/docs/api/ 的文档。对于日历class,有以下段落:
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
描述的有点看不懂,尤其是被“同义词”这个词搞糊涂了。如果有人能给我解释一下这段话,我将不胜感激。
一个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_MONTH
或 Calendar.DATE
。您将始终获得相同的值。
我们可以通过查看 documentation for Calendar
:
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.
两个字段的文档完全相同。
同义词表示具有相同的含义。
在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,所以都是一样的