Java class envelopes



  • The object of any of the chassis classes is a complete specimen of the dynamic memory in which its unchangeable value is stored. What does it mean by an unchangeable meaning?



  • The inevitable value is the value of the primitive for which the object is the sheath. For example, int - The shell. java.lang.Integer for long - the shell... java.lang.Long

    To be sure, the class reference code is open. java.lang.Integer :

    /**
     * The value of the {@code Integer}.
     *
     * @serial
     */
    private final int value;
    

    /**

    • Constructs a newly allocated {@code Integer} object that
    • represents the specified {@code int} value.
    • @param value the value to be represented by the
    •              {@code Integer} object.
      

    */
    public Integer(int value) {
    this.value = value;
    }

    That's it. private final int value and there's an irreplaceable value.

    UPD:I mean, it's an announcement. Integer somevar = 1; In fact, something like: Integer somevar = new Integer(1); Next, if we want to change the meaning somevar = 2 - the variable. somevar will be listed on another site, not reset the value of the previous one. The previous facility will be assembled by a sour collector if no reference is made to it.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2