• 循坏语句


    break可以在switch和循坏语句中使用

    continue只能在循坏结构中使用

    1.if ……else

    int a=14;
    	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");
    	}
    

    2.switch

    char d='B';
    	switch(d) {
    	case 'A':
    		System.out.println("80~100");
    		break;
    	case 'B':
    		System.out.println("70~80");
    		break;
    	case 'C':
    		System.out.println("60~70");
    		break;
    	default:
    		System.out.println("60以下");
    

    3.for循坏

    	String s="";
    	for(int a=1;a<10;a++) {
    		for(int b=1;b<=a;b++) {
    		s+=a+"*"+b+"="+(a*b)+"	";
    		}
    		s+="
    ";
    	}
    	System.out.println(s);
    	
    

    4.do……while

    	int a=1;
    	String s="";
    	do {
    		int b=a;
    		do {
    		s+=a+"*"+b+"="+(a*b)+"	";
    		b++;
    		}while(b<10);
    		s+="
    ";
    		
    		a++;
    		
    	}while(a<10);
    	System.out.println(s);
    
    

    5.while

    int a=1;
    	String s="";
    	while(a<10) {
    		int b=a;
    		while(b<10
    				) {
    			s+=a+"*"+b+"="+(a*b)+"	";
    			b++;
    		}
    		a++;
    		s+="
    ";
    	}
    System.out.println(s);
    }
    
  • 相关阅读:
    ajax 前台返回后台传递过来的数组
    js中push的用法
    split 的用法
    ckeditor上传图片
    FTP安装配置
    批量删除.svn文件
    Ext flex属性
    Extjs3 主题样式
    Ext.apply与Ext.applyIf
    SharePoint2010 Office Web Apps
  • 原文地址:https://www.cnblogs.com/zh93/p/12534060.html
Copyright © 2020-2023  润新知