Click or drag to resize

Out Parameters

Because STK Components was originally developed for the .NET Framework, some subsystems require the use of out parameters. Since this language feature is not available in Java, we use single-element arrays to to achieve the same effect.

Because Java methods are always pass-by-value, we need to pass a value that can then be modified by the method in order to carry a new reference back to the caller. For simplicity we use a single-element array, and modify the 0th element of the array.

The following example uses the tryConvertTimeStandard method, which attempts to convert a date from one TimeStandard to another, returning a boolean indicating whether the conversion was successful.

JulianDate originalDate = new JulianDate(2453736, 43233d, TimeStandard.getInternationalAtomicTime());
JulianDate[] out_date = new JulianDate[1];

boolean result = originalDate.tryConvertTimeStandard(TimeStandard.getCoordinatedUniversalTime(), out_date);
// result => true

JulianDate date = out_date[0];
// date.getStandard() => Coordinated Universal Time (UTC)

In this example, the conversion is successful, as indicated by the return value, and the converted value is returned in the out_Date parameter's 0th element.