Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8530685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:18:21+00:00 2026-06-11T09:18:21+00:00

In the following code the set method changes the field values of Calendar class.

  • 0

In the following code the set method changes the field values of Calendar class.
The field YEAR is declared static int YEAR. So why by creating two objects of Calendar class, the changes to one object will reflect to the other? Here this doesn’t happen.
I would ask you how Java developers have implemented this?

Calendar calendar = new GregorianCalendar();
Calendar cal = new GregorianCalendar(2011,9,13);
System.out.println(calendar.get(Calendar.YEAR));
System.out.println(cal.get(Calendar.YEAR));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T09:18:23+00:00Added an answer on June 11, 2026 at 9:18 am

    Calendar.YEAR is a constant that is only used to name a field used by the Calendar. The value of that field is not static: it can and will vary between instances of Calendar.

    Calendar defines a number of these field names for the different components of date and time, specifically to be used with get and set operations for the corresponding fields.

    Here’s the section in the javadoc for Calendar.YEAR.

    As for the implementation, the set and get methods are aware of these different field types, and change values in the instance based on the constant passed in. Think of it like a big switch statement in get or set, switching on all the field values.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider the following code snippet: class Test { public int Length{ get; set; }
I have set the following code in a viewWillAppear method. - (void)viewWillAppear:(BOOL)animated { //some
I have the following code set up in my Startup IDictionary<string, string> properties =
In the following code I set up a change handler on a select box
I have the following code to set a userId variable: (userId set in prior
Why does the following ARM code set R0 to 0 after the SWI ?
I have used the following code to set cookie and then redirect. String level=(String)
I am using the following code to set the full permission for a file
i am new to android development. I am use the following code to set
The following code does not set the comment: string userName = yrtre.etre.423369a9-3e57-42da-934d-dae91f87a1e4; MembershipUser user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.