Sample Programs in java

Java Example Program to display Numbers from 1 to N using While Loop

[java]
/**
@author:candidjava.com
@description:Program to display Numbers from 1 to N using While Loop
*/
public class displaynumbers {
public static void main(String org[]) {
int i = 1;
int N = 10;// take variable N value is 10
while (i <= N)// condition for print 1 to N values
{
System.out.println(i);
i++;
}
}
}
[/java]

Output:
1
2
3
4
5
6
7
8
9
10