VOOZH about

URL: https://www.geeksforgeeks.org/java/java-file-class-equals-method-with-examples/

⇱ Java File Class equals() Method with Examples - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

Java File Class equals() Method with Examples

Last Updated : 2 Feb, 2022

The equals() method of Java File Class compares the pathname supplied in the argument to the pathname provided in the argument. If the parameter is not null and points to the same file or directory, this function returns true. The operating system determines if the two abstract pathnames are equivalent or not.

Syntax:

public boolean equals(Object obj)

Parameters:

  • obj - The item against which the abstract pathname is to be compared

Return Value: It returns true, if and only if the items are the same; otherwise, false.

Example:

The method compares two File instances to see whether they are the same. This approach does not compare the content of the file or directory; instead, it checks if the pathnames are the same.

Output:

👁 Image
Comment
Article Tags: