Thread: Explain static
View Single Post
Old 08-15-2008, 03:57 AM   PM User | #4
icm9768
New Coder

 
Join Date: Jun 2005
Posts: 32
Thanks: 0
Thanked 2 Times in 2 Posts
icm9768 is an unknown quantity at this point
It would be Student.getStudentNum(). Static variables are shared among ALL instances of the class so it doesn't require you to reference it via any particular instance (bob in your case), nor should you for clarity sake. Using Student.bob.getStudentNum() would work, but it will create a warning when you compile your code.

Just as a side note, in case you didn't already realize, that each Student class you instantiate will not have a unqiue studentNum. Every instance will have the same id (i.e. The total number of Student objects you have created).

Last edited by icm9768; 08-15-2008 at 03:59 AM..
icm9768 is offline   Reply With Quote
Users who have thanked icm9768 for this post:
twodayslate (08-15-2008)