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

Why it gets incremented?

Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 436
Why is the final int id gets incremented?




Thanks,

Maki Jav

Help gets you when you need it!
Raymond Tong
Ranch Hand

Joined: Aug 15, 2010
Posts: 230
    
    2

nextId is like a visitor counter
id is the snapshot of visitor counter

nextId uniqueness ensured by calling nextId++ when each instance created
Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 436
True; but the final id is not throwing any exceptions...
John Jai
Bartender

Joined: May 31, 2011
Posts: 1776
The final variable id never gets incremented and always have the value that it has been initialized with.

While creating different objects, the static nextId gets incremented and assigned to the instance variable id - but once assigned the id variable stays unmodified for the instance with which it's associated.

Maki Jav
Ranch Hand

Joined: May 09, 2002
Posts: 436
Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why it gets incremented?