alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Groovy example source code file (ary.groovy)

This example Groovy source code file (ary.groovy) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Groovy tags/keywords

The Groovy ary.groovy source code

// $Id: ary.java,v 1.1 2004-05-22 07:27:00 bfulgham Exp $
// http://www.bagley.org/~doug/shootout/

// this program is modified from:
//   http://cm.bell-labs.com/cm/cs/who/bwk/interps/pap.html
// Timing Trials, or, the Trials of Timing: Experiments with Scripting
// and User-Interface Languages</a> by Brian W. Kernighan and
// Christopher J. Van Wyk.


public class ary {
    public static void main(String args[]) {
	int i, j, k, n = Integer.parseInt(args[0]);
	int x[] = new int[n];
	int y[] = new int[n];

	for (i = 0; i < n; i++)
	    x[i] = i + 1;
	for (k = 0; k < 1000; k++ )
	    for (j = n-1; j >= 0; j--)
		y[j] += x[j];

	System.out.println(y[0] + " " + y[n-1]);
    }
}

Other Groovy examples (source code examples)

Here is a short list of links related to this Groovy ary.groovy source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.