Scanner hashCode() in Java

hashCode(): This method is available in java.util.Scanner 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

import java.util.Scanner;

public class ScannerhashCode {
    public static void main(String[] args) {

        String source = "Hello World";
        Scanner scanner = new Scanner(source);

        System.out.println(scanner.hashCode());
        scanner.close();
    }
}

Output:

1449621165


No comments:

Post a Comment