How do I retrieve a value from two objects in Java? -


i want following:

myobject obj1 = new myobject(); myobject obj2 = new myobject(); myobject obj3 = new myobject(); myobject obj4 = new myobject();  values[obj1][obj2] = 1; values[obj2][obj4] = 2; values[obj1][obj4] = 3;  int somevalue = values[obj1][obj2]; int someothervalue = values[obj2][obj4]; int anothervalue = values[obj1][obj4]; 

how create these getter , setters 2 objects key in java?

you can use class return 2 object.. may can work around this

    final class myresultobject {             private final myobject firstobject;             private final myobject secondobject;         private final int key;             public myresult(myobject firstobject, myobject secondobject ,int key) {                 this.firstobject = firstobject;                 this.secondobject = secondobject;                 this.key=key;             }       public int getkey() {                 return key;             }     public int getkeyvalue(myobject object1, myobject object2){  }         }         //and can workaround         public static void main(string[] args) {             myresultobject resultob = new myresultobject(obj1,obj2,1);             system.out.println(resultob.getfirstobject() + resultob.getsecondobject());         } 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -