Problem With Java Generic Interface passed to Generic Constructor -


i have interface , class , both compile fine. when try instantiate separator anonymous implementation of namer fails compile.

private interface namer<n> {     string getname(n o); };  private static class separator<h> {     hashset<h> olddiff;     hashmap<string, h> newfamap;      public separator(hashset<h> older, hashset<h> newer, namer<h> namer)     {         olddiff = new hashset<h> (older);         hashset<h> newdiff = new hashset<h> (newer);         olddiff.removeall(newer);         newdiff.removeall(older);         newfamap = makemap(newdiff, namer);     }      private hashmap<string, h> makemap(hashset<h> set, namer<h> namer)     {         hashmap<string, h> map = new hashmap<string, h>();         (h holder : set)         {             map.put(namer.getname(holder), holder);         }          return map;     } } 

in method

        namer<faholder> namer = new namer<faholder>() {              public string getname(faholder o)             {                 return o.getname();             }         };          new separator<faholder>(older, newer, namer); 

the compile error is:

the constructor myclass.separator<faholder>(set<faholder>, set<faholder>, myclass.namer<faholder>) undefined

what have overlooked?

it looks static type of older , newer set<faholder> , not hashset<faholder>. change constructor's signature from:

public separator(hashset<h> older, hashset<h> newer, namer<h> namer) 

to

public separator(set<h> older, set<h> newer, namer<h> namer) 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -