Java examples for Language Basics:for
Counter-controlled repetition with the for repetition statement.
public class Main { public static void main(String[] args) {/* w w w .ja v a 2 s . c o m*/ // for statement header includes initialization, // loop-continuation condition and increment for (int counter = 1; counter <= 10; counter++) System.out.printf("%d ", counter); System.out.println(); } }