hashCode(): This method is available in java.lang.Object class of Java.
Syntax:
int java.lang.Object.hashCode()
This method returns a hash code value for the object.
Parameters: NA
Returns: a hash code value for this object.
Exceptions: NA
Approach
Java
public class ObjecthashCode {public static void main(String[] args) {// String objectObject obj = "Java is a progrmming language.";System.out.println(obj.hashCode());}}
Output:
1975900631
Some other methods of Object Class.
equals(): This method indicates whether some other object is "equal to" this one.
getClass(): The returned Class object is the object that is locked by static synchronized methods of the represented class.
toString(): This method returns a string representation of the object.
No comments:
Post a Comment