Java examples for Language Basics:for
Use two counter in for loop
public class CountBothWays { public static void main(String[] args) {//from www . j a va2 s. c o m int a, b; for (a = 1, b = 10; a <= 10; a++, b--) System.out.println(a + " " + b); } }