Java File.hashCode() method example

 Posted On  | Pooja Lakkihal 

In this java tutorial, You will learn how to get the hash code for the abstact pathname. Java File.hashCode() method computes a hash code for this abstract pathname.partition named by this abstract pathname.

Computes a hash code for this abstract pathname.

syntax

public int hashCode()

Returns

A hash code for this abstract pathname.

Java File hashCode() example

  • Create file instance new File("c:\\technicalkeeda\\test.txt");
  • file.hashCode() Get the Hash code value of file.
package com.technicalkeeda;

import java.io.File;

public class App {

    public static void main(String[] args) {

        File file = new File("c:\\technicalkeeda\\test.txt");

        System.out.println("Hash code of this file :- " + file.hashCode());

    }
}

output

Hash code of this file :- -1107075599


© technicalkeeda.com 2018

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0432 seconds.