File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Head First Android this week in the Android 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: 63052

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
It's not a secret anymore!