@Constant public interface ValueType
A constant object which can be manipulated by value
rather than by reference; a JVM implementation may allocate instances
of this class on the stack.
public class Complex implements ValueType { // Complex numbers can be manipulated by value. ... @Override public boolean equals(Object obj) { ... } // Must compare values. @Override public int hashCode() { ... } // Must return value hash code. }
Note: "Stack" allocation is not the only optimization that a VM
can do on ValueType. The VM might decide not to perform any
allocation at all and store values directly in registers.
boolean equals(Object obj)
true if this object has the same value content as the
the one specified; false otherwise. The default object
equals must be overridden to ensure the same behavior whether or
not the instance is allocated on the stack.Copyright © 2017. All rights reserved.