File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Effects of Static Variables when Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Effects of Static Variables when" Watch "Effects of Static Variables when" New topic
Author

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
Marshal

Joined: Jan 10, 2002
Posts: 56529
    
  14

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


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About 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: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: Effects of Static Variables when
 
Similar Threads
Difference static and non static method
StackOverflowException
When to use a private static method?
inner
Nested enum in enum.