FICO
FICO Xpress Optimization Examples Repository
FICO Optimization Community FICO Xpress Optimization Home
Back to examples browserNext example

Passing single values from a Mosel model to a Java method

Description
Demonstrates calling a Java method from a Mosel model, passing in a string and an integer, and receiving a string. You must compile the Java file before running the example - e.g. javac PassValues.java

mosjvm_passingvalues.zip[download all files]

Source Files
By clicking on a file name, a preview is opened at the bottom of this page.
passvalues.mos[download]
PassValues.java[download]





PassValues.java

/**
 * Example Java class, containing a method that returns a string based on arguments passed to it
 *
 * @author  J.Farmer, (c) Fair Isaac Corporation, 2016
 **/
public class PassValues {
	public static String repeatValue(String value, int nRepetitions) {
		StringBuilder result = new StringBuilder();
		for (int i=0;i<nRepetitions;i++) {
			result.append(value);
		}
		return result.toString();
	}
}
Back to examples browserNext example