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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 19542
    
  16

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: 36478
    
  16
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
 
Similar Threads
Difference between the two statements
explain why the following will compile
JQ+ Inner Class Question
Request for scrunched up code listings
static block