/**
* java常见的控制流语句
* @author javawg
* @version 2016-11-20
* */
public class IfTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 3 ;
int b = 5 ;
if(a > b) {
System.out.println("A > B");
} else if(a < b) {
System.out.println("A < B");
} else {
System.out.println("A == B");
}
}
}
/**
* switch case 条件控制语句
* @author javawg
* @version 2016-11-20
* */
public class SwitchTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a =2 ;
switch(a) {
case 1 :
System.out.println("a=1");
break ;
case 2 :
System.out.println("a=2");
break ;
case 3 :
System.out.println("a =3");
break ;
default :
System.out.println("默认输出结果");
}
}
}
/**
* 条件控制语句 while
* @author javawg
* @version 2016-11-20
* */
public class WhileTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 1 ; //循环变量
int sum = 0 ; //存储循环增加后的结果。
while(a <100) {
sum += a ;
a++;
}
System.out.println("循环输出结果:"+sum);
}
}