简体   繁体   中英

What does “synonym” mean in Java?

I read the JAVA API Document from http://docs.oracle.com/javase/8/docs/api/ . For calendar class, there is the following paragraph:

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

I hardly understand the description, especially confused by the word "synonym". I will really appreciate it if anyone could explain this paragraph to me.

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. (...)

So it means something has a different (field)name to refer to the same thing .

So the documentation specifies that if you call Calendar.DAY_OF_MONTH or Calendar.DATE . you will always obtain the same value .

We can verify this when we look at the 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.

The documentation for both fieds is exactly the same .

Synonym means having same meaning.

In the source code of 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;

Here both values are 5, so both are same.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM