Object & Wrapper - Day 6 Flashcards
Object class
Implicit super class of all classes.
Commonly used methods of object class: equals(), hashCode(), toString()
Equals method
.equals() compares objects to check for equality
Needs overrideing in the class for it to work for different requirements.
hashCode()
Uses object’s data to generate hash value (32 bit integer)
If two objects are equal, hashCode() must produce the same int value for the objects
^ NOT ALWAYS EQUAL IF HASHCODE IS THE SAME
uses formula to generate integer
Equals and hashcode must be overridden together
toString()
Returns a textual representation of an object
Wrapper class
Convert data types into objects in Java programming.
Boolean, Character, Integer, Long, Float and Double classes
Help represent the primitive data types as objects.
Belong to java.lang package