The following Java code defines a Problem through method calls

import qs.*;

/**
 * @author monika, All Rights Reserved 
 *
 */
public class define {

   /*       Maximize  3.0x + 2.0y + 4.0z                   */
   /*       Subject to                                     */
   /*                 3.1x + 2.3y + 1.4z <= 12.2           */
   /*                 5.0x + 1.1y         = 10.0           */
   /*                 x >= 2.0                             */
   /*                 y free                               */
   /*                 1.0 <= z <= 10.0                     */
   /*                                                      */


   public static void main(String[] args) throws QSException {
      Problem prob = new Problem("define");

      prob.change_objsense (QS.MIN); 
      { // add 2 rows and define their right hand sides 
         double rhs[] = { 12.2, 10.0 };
         char sense[] = { 'L', 'E' };
         int matcnt[] = { 0, 0, 0 };
         int matbgn[] = { 0, 0, 0 };
         prob.add_rows(2, matcnt, null, null, null, rhs, sense, null);
      }

      { // add variables x, y, z, 
        // add with coeffs to rows c1-c2 and to objective 
        // define their bounds
         int matcnt[] = { 2, 2, 1};
         int matbgn[] = { 0, 2, 4 }; 
         int matind[] =  { 0, 1, 0, 1, 0 }; 
         double matval[] = { 3.1, 5.0, 2.3, 1.1, 1.4 };
         double obj[] = { 3.0, 2.0, 4.0};
         double lower[] = { 2.0, -QS.MAXDOUBLE, 1.0}; 
         double upper[] = { QS.MAXDOUBLE, QS.MAXDOUBLE, 10.0 }; 
         String names[] = { "x", "y", "z" };
         
	 prob.add_cols(3, matcnt, matbgn, matind, matval, 
                          obj, lower, upper, names);
      }

      prob.write(new Reporter(System.out), false);
   }
}