Java List of Pairs -


i'm trying create list of pairs of integers. think have basic idea right i'm getting error whenever try add new pair list.

here pair class:

public class pair<l,r> {     private l l;     private r r;     public pair(l l, r r){         this.l = l;         this.r = r;     }     public l getl(){ return l; }     public r getr(){ return r; }     public void setl(l l){ this.l = l; }     public void setr(r r){ this.r = r; } } 

here create new list of pairs:

private arraylist<pair<short,short>> dominolist = new arraylist<pair<short,short>>(); 

and here example of try add new pair dominolist:

dominolist.add(0, pair<0,0>); 

does see blatantly wrong way doing this? feel i'm missing simple, cant figure out what's wrong. feel adding new pairs incorrectly.

you should call constructor create new pair instance. use

dominolist.add(0, new pair(0, 0)); 

you said want pairs of integers. shouldn't use short integer instead.


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -