home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
BUG 15
/
BUGCD1998_06.ISO
/
aplic
/
jbuilder
/
jsamples.z
/
Counting2.java
< prev
next >
Wrap
Text File
|
1997-07-30
|
759b
|
36 lines
// Copyright(c) 1997 ObjectSpace, Inc.
import COM.objectspace.jgl.*;
/**
* Sum the values of a range using a binary function.
*
* @see COM.objectspace.jgl.Counting
* @version 2.0.2
* @author ObjectSpace, Inc.
*/
public class Counting2
{
public static void main( String[] args )
{
Array array = new Array();
array.add( new Long( 5 ) );
array.add( new Long( 4 ) );
array.add( new Long( 3 ) );
array.add( new Long( 2 ) );
array.add( new Long( 1 ) );
Number prod = new Long( 1 );
prod = Counting.accumulate
(
array.start(),
array.finish(),
prod,
new TimesNumber( prod.getClass() )
);
System.out.println( "Product = " + prod );
}
}