14 May String hashCode() method in Java
The hashCode() method in Java returns a hash code for this string.
Syntax
Let us see the syntax,
1 2 3 |
int hashCode() |
Parameters
The method has no parameters.
Example
The following is an example of hashCode(),
1 2 3 4 5 6 7 8 9 10 11 12 13 |
public class StudyopediaDemo { public static void main(String args[]) { String message1 = new String("Australia is a country!"); System.out.println("Hashcode= " + message1.hashCode() ); String message2 = new String("India is a country!"); System.out.println("Hashcode= " + message2.hashCode() ); } } |
Output
The following is the output,
No Comments