File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Java 7 Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 225


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 ?


OCAJP
meeta gaur
Ranch Hand

Joined: Dec 05, 2012
Posts: 225

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

Joined: Aug 07, 2007
Posts: 1156
    
    3

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: 225

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