if条件语句:if...; if ...else ...; if... else if ...else
switch分支语句:switch(i){ case 1: {System.out.println(""); break;} default: System.out.println("");}
while循环: while(i>1){i--;}
do{}While()循环:Do{}while();
for循环:for(int i=0; i<10;i++){System.out.println(i);}
break, continue;
public class CalculateClass {
public static void main(String[] args) {
int x= 4;
System.out.println(SUM(x));
System.out.println(Mul(x));
}
public static int SUM(int x)
{
int sum = 0;
while(x>10)
{
sum = sum + x%10;
x = x/10;
}
sum += x;
return sum;
}
public static float Mul(int x)
{
float result = 1;
while(x>0)
{
result *= x;
x--;
}
return result;
}
}
原文:http://www.cnblogs.com/yanmantianxia/p/5450890.html