
04-18-2008, 08:09 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 2,396
|
|
|
Static fields
Hi all,
All of you know about static fields(class variable). I just want to see your opinion on one thing, just make your comment here, not a question at all. 
public class MyClass {
static int myNumber = 0; // class variable
// do the rest of processing of MyClass
}
In the above class I've initialized a static field. I can refer that in two ways.
- Using the class name
- Using an object reference
Something like this.
MyClass.myNumber
myClassObject.myNumber
Actually even I courage to use the first way to do this, because the variable is a class level(I mean class variable) and easy to differ it from others.
But some people says that, the second way is the easiest because it is common to refer locals.
What is your comments on it.
Eanga
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. (Close on July 13, 2008)
|