This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Java 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Java 7 "Diamond in Generic"" Watch "Java 7 "Diamond in Generic"" New topic
Author

Java 7 "Diamond in Generic"

meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305


FileFilter.java:13: error: cannot infer type arguments for Filter<T>;
DirectoryStream.Filter<Path> fileFilter=new DirectoryStream.Filter<>(){
^

1 error

Normally it works like List<String> list=new ArrayList<>();

But why it isn't working above ?


My one regret in life is that I am not someone else.
- Woody Allen
meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

It seems Diamond doesn't work with inner class.
Tony Docherty
Bartender

Joined: Aug 07, 2007
Posts: 2173
    
  47
It seems Diamond doesn't work with inner class.

It does work with inner classes but not with anonymous inner classes.

According to the JLS section 15.9:
"It is a compile-time error if a class instance creation expression declares an anonymous class using the "<>" form for the class's type arguments."
meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 305

Thank you.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java 7 "Diamond in Generic"
 
Similar Threads
excluding files using FileFilter
Strange StackOverflowError
Cant load files into array using listFiles. I think it's an eclipse problem
Problem inputting and outputting strings correctly (weird error)
FileFilter cannot be the superclass of ImageFilter?