This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach 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 Murach's Java Servlets and JSP this week in the Servlets 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: 2165
    
  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
Problem inputting and outputting strings correctly (weird error)
FileFilter cannot be the superclass of ImageFilter?
Cant load files into array using listFiles. I think it's an eclipse problem