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
ConstructorsConstructorDescriptionAllocation(long size, long startingAddress) Creates an instance of aAllocationrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintbooleanIndicates whether some other object is "equal to" this one.inthashCode()Returns a hash code value for this object.longsize()Returns the value of thesizerecord component.longReturns the value of thestartingAddressrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
Allocation
public Allocation(long size, long startingAddress) Creates an instance of aAllocationrecord class.- Parameters:
size- the value for thesizerecord componentstartingAddress- the value for thestartingAddressrecord 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:
compareToin 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 thesizerecord component.- Returns:
- the value of the
sizerecord component
-
startingAddress
public long startingAddress()Returns the value of thestartingAddressrecord component.- Returns:
- the value of the
startingAddressrecord component
-