[英]What does “synonym” mean in Java?
我從http://docs.oracle.com/javase/8/docs/api/閱讀了JAVA API文檔。 對於日歷類,有以下段落:
DAY_OF_MONTH
公共靜態最終int DAY_OF_MONTH
get和set的字段編號,指示每月的日期。 這是DATE的同義詞。 該月的第一天的值為1。
也可以看看:
DATE,常量字段值
我幾乎不理解該描述,尤其是與“同義詞”一詞相混淆。 如果有人可以向我解釋這一段,我將不勝感激。
同義詞是 :
同義詞 名詞 。 1.與另一個語言具有相同或幾乎相同的含義的單詞,如快樂,快樂,興高采烈。 同義詞和反義詞(或反義詞)的字典。 2.(...)
因此,這意味着某事物具有不同的(字段)名稱來引用同一事物 。
因此,文檔指定了如果您調用Calendar.DAY_OF_MONTH
或Calendar.DATE
。 您將始終獲得相同的值 。
static int DATE
get和set的字段編號,指示每月的日期。
static int DAY_OF_MONTH
get和set的字段編號,指示每月的日期。
這兩個領域的文檔完全相同 。
同義詞意味着具有相同的含義。
在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,因此兩者相同。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.