Do While
package javaapplication7;
public class JavaApplication7 {
public static void main(String[] args)
{
int i=10;
do
{
System.out.println(i);
i--;
} while (i>0);
}
}
Foreach
package javaapplication8;
public class JavaApplication8 {
public static void main(String[] args)
{
String[] fruits = new String[] { "Orange", "Apple", "Pear", "Strawberry" };
for (String x : fruits)
{
System.out.println(x);
}
}
}
No comments:
Post a Comment