This week's book giveaway is in the Big Data forum.
We're giving away four copies of Elasticsearch in Action and have Radu Gheorghe & Matthew Lee Hinman on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Effects of Static Variables when Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Elasticsearch in Action this week in the Big Data forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Effects of Static Variables when" Watch "Effects of Static Variables when" New topic

Effects of Static Variables when

Paul Okeke
Ranch Hand

Joined: May 16, 2009
Posts: 58
I reaaly want to the implication of calling static members of a class with an instance of such class. For example, Calendar now=Calendar.getInstance(); now.setTimeInMilis(someLongValue); now.MONTH; it gave some incorrect value but i want to know why?

OCJP 1.6
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 62130

What do you think now.MONTH should have returned?

If you think it was the month of the loaded date, then you are not correct. now.MONTH is simply a key to be passed to into method such as get() and set();

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Paul Okeke
Ranch Hand

Joined: May 16, 2009
Posts: 58
At the begging I thought it will return the loaded Date but I found that I was long. Thanks for your concern.
I agree. Here's the link:
subject: Effects of Static Variables when