Class Counter

  • All Implemented Interfaces:
    java.io.Externalizable, java.io.Serializable

    public final class Counter
    extends java.lang.Object
    implements java.io.Externalizable
    A Counter can be used to increment and return an integer count. A Counter can be used in Anonymous inner classes if it is declared final, unlike an int, which once declared final cannot be modified.
    See Also:
    Serialized Form
    • Constructor Detail

      • Counter

        public Counter​(int startCount)
      • Counter

        public Counter()
    • Method Detail

      • increment

        public void increment()
      • decrement

        public void decrement()
      • add

        public void add​(int value)
      • getCount

        public int getCount()
      • reset

        public void reset()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • writeExternal

        public void writeExternal​(java.io.ObjectOutput out)
                           throws java.io.IOException
        Specified by:
        writeExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException
      • readExternal

        public void readExternal​(java.io.ObjectInput in)
                          throws java.io.IOException
        Specified by:
        readExternal in interface java.io.Externalizable
        Throws:
        java.io.IOException