public class test_for { public static void main (String[] argv) { // Computes (1/10 + 2/9 + ... + 10/1 - 1) int n = 10; double sum = 0; // Notice how i and j are both defined in the for-loop. for (int i=1, j=n; (i!=j)&&(i<=n); i++, j--) sum += (double) i / (double) j; System.out.println ("Sum = " + sum); } }