wood burning stoves 2.0*
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
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: 2364
    
  50
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"