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.


public int hashCode()


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;


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());



Hash code of this file :- -1107075599

© 2018

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0432 seconds.