aspose file tools*
The moose likes Beginning Java and the fly likes Static Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Static" Watch "Static" New topic
Author

Static

shruti patel
Ranch Hand

Joined: Mar 10, 2008
Posts: 52
class A{
static int i=20;
int j=10;
}

If i will create 10 objects of the above class.
then how many i's and j'S will be available?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19761
    
  20

If a field is marked as static, there is just one value for all instances of the class. Otherwise, there is one value for each instance.

So if you create 10 objects (instances), there will be 1 i and 10 j's.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Originally posted by Rob Prime:
So if you create 10 objects (instances), there will be 1 i and 10 j's.


hi Rb prime good explanation,

where these i and j are store?... and how these copies are created? please can you explain me?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39845
    
  28
Whenever I want that sort of information, I go to the BCEL Manual.

Not at all easy to read, but it should explain your question.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Thanks Campbell
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Static