Class IntHolder


  • public class IntHolder
    extends java.lang.Object
    Represents a modifiable int.
    Author:
    Holger Eichelberger
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int value  
    • Constructor Summary

      Constructors 
      Constructor Description
      IntHolder()
      Creates the int holder with default initial value of 0.
      IntHolder​(int value)
      Creates the int holder.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int getAndDec()
      Returns the int value decremented by 1.
      int getAndInc()
      Returns the int value incremented by 1.
      int getValue()
      Returns the int value.
      void setValue​(int value)
      Changes the int value.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • value

        private int value
    • Constructor Detail

      • IntHolder

        public IntHolder()
        Creates the int holder with default initial value of 0.
      • IntHolder

        public IntHolder​(int value)
        Creates the int holder.
        Parameters:
        value - the initial value
    • Method Detail

      • setValue

        public void setValue​(int value)
        Changes the int value.
        Parameters:
        value - the new value
      • getValue

        public int getValue()
        Returns the int value.
        Returns:
        the int value
      • getAndInc

        public int getAndInc()
        Returns the int value incremented by 1.
        Returns:
        the int value
      • getAndDec

        public int getAndDec()
        Returns the int value decremented by 1.
        Returns:
        the int value
      • toString

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