For the objective, you can do something like:
// Set objective: minimize (sum(Ap) - (h'*w))
GRBQuadExpr obj = new GRBQuadExpr();
for (double value: Ap) obj.addConstant(value);
for (int i = 0; i < h.length; i++) obj.addTerm(-1.0, h[i], w[i]);
model.setObjective(obj, GRB.MINIMIZE);
Note that this means you are minimizing a non-convex quadratic function, which is not supported by Gurobi.
Assuming r is an array, then you want to create a constraint for each value of r? If so, you can do something like:
// Add constraints: y(1) + h(1) - h(8) <= mod (hp(1), con) - r
for (double value: r)
{
GRBLinExpr expr = new GRBLinExpr();
expr.addTerm(1.0, y[0]);
expr.addTerm(1.0, h[0]);
expr.addTerm(-1.0, h[7]);
double rhs = (hp[0] % con) - value;
model.addConstr(expr, GRB.LESS_EQUAL, rhs, "");
}
Note that Matlab indexes from 1 to n, while Java indexes from 0 to n-1. Also, you shouldn't use the variable name 'const' in Java, since it's a keyword.