• Post Reply Bookmark Topic Watch Topic
  • New Topic

The method list(FilenameFilter) in the type File is not applicable for the arguments (FilenameFilter  RSS feed

 
Rajkumar Masanaiyan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have pasted my code at the bottom and I am getting the following error. The example is picked from "Thinking in Java" by Bruce Eckel. Would you please let me know the problem with the below mentioned code?

Exception in thread "main" java.lang.Error: Unresolved compilation problem:
The method list(FilenameFilter) in the type File is not applicable for the arguments (FilenameFilter)
at com.sample.InnerClass.main(InnerClass.java:37)

-----------------------
 
Joanne Neal
Rancher
Posts: 3742
16
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You need to pass an instance of a class that implements the java.io.FilenameFilter interface - not your own interface called FilenameFilter.
 
Harsha Smith
Ranch Hand
Posts: 287
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The author was only showing you the interface and what all methods it contains. You don't have to re-invent the wheel.

As told by the above poster, pass an instance of java.io.FileNameFilter. so remove that interface from your compilation unit and you should be good.
 
Rajkumar Masanaiyan
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Harsha Smith wrote:The author was only showing you the interface and what all methods it contains. You don't have to re-invent the wheel.

As told by the above poster, pass an instance of java.io.FileNameFilter. so remove that interface from your compilation unit and you should be good.


Thank you Joanne & Harsha.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!