[Java] anonymous inner class issue
It seems that if an anonymous inner class implements an interface ,then its constructor can't have argument。If really need arguments, theorectically two solutions: define a method which takes arguments (must be " final "). The method does nothing but return an anonymous class, which uses the method's arguments。 public Destination dest(final String dest) { return new Destination() { private String label = dest; public String readLabel() { return label; } }; } see the exmaple below: import java.io.*; import java.util.*; abstract class NewFilenameFilter implements FilenameFilter{ protected String start, end; NewFilenameFilter(String s, String e){ start = s; end = e; } } public class NameFilter{ public static void main(String argv[]){ if(argv.length != 1){ System.out.println("must have one argument!"); System.exit(1); } File f = new File(a