java 第四章

来源:互联网 发布:椭圆拟合编程 编辑:程序博客网 时间:2024/05/21 09:15

switch ,只能处理等值的情况,且,表达式必须为byte,short,int,char,不能是string,double,float,,另外,记得每种情况后,要加break,


然后是do while  和while的用法,for循环的使用,经典的例子,

一、求,1到10的阶乘

int sum=0;for(int i=1;i<=10;i++){   int s=0;   for(int j=i;j>=1;j++){    s*=j;}sum+=s;}System.out.println(sum);