invoke cplex variable from an other function in java -
how can invoke cplex (ilocplex cplexx = new ilocplex();) variable other function? because need use frequantly other functions cant because behaves local variable.
make global variable?
as such:
public class myclass{ private ilocplex cplexx; public myclass(){ cplexx = new ilocplex(); } //use cplexx anywhere in myclass this.cplexx }
if want use same cplex make getter adding method myclass:
public ilocplex getcplexx(){ return this.cplexx; }
and in other classes can go this:
public class main{ public static void main(string args[]){ myclass mine = new myclass(); mine.getcplexx().solve(); //or other logic system.out.println(mine.getcplexx().getobjvalue()); } }
hope helps
Comments
Post a Comment