Package ch.hslu.exercises.sw02.ex2
Record Class Allocation
java.lang.Object
java.lang.Record
ch.hslu.exercises.sw02.ex2.Allocation
- All Implemented Interfaces:
Comparable<Allocation>
public record Allocation(long size, long startingAddress)
extends Record
implements Comparable<Allocation>
-
Constructor Summary
ConstructorDescriptionAllocation
(long size, long startingAddress) Creates an instance of aAllocation
record class. -
Method Summary
Modifier and TypeMethodDescriptionint
boolean
Indicates whether some other object is "equal to" this one.int
hashCode()
Returns a hash code value for this object.long
size()
Returns the value of thesize
record component.long
Returns the value of thestartingAddress
record component.final String
toString()
Returns a string representation of this record class.
-
Constructor Details
-
Allocation
public Allocation(long size, long startingAddress) Creates an instance of aAllocation
record class.- Parameters:
size
- the value for thesize
record componentstartingAddress
- the value for thestartingAddress
record component
-
-
Method Details
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
hashCode
public int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
compareTo
- Specified by:
compareTo
in interfaceComparable<Allocation>
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
size
public long size()Returns the value of thesize
record component.- Returns:
- the value of the
size
record component
-
startingAddress
public long startingAddress()Returns the value of thestartingAddress
record component.- Returns:
- the value of the
startingAddress
record component
-