Specifications
Sun Services
Java™ Programming Language
Module 7, slide 6 of 44
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Class Attributes
If the static member is public:
1 public class Count1 {
2 private int serialNumber;
3 public static int counter = 0;
4 public Count1() {
5 counter++;
6 serialNumber = counter;
7 }
8}
it can be accessed from outside the class without an instance:
1 public class OtherClass {
2 public void incrementNumber() {
3 Count1.counter++;
4 }
5}










