控制语句: Demo_ForPower
1 package www.control; 2 3 public class Demo5_ForPower { 4 public static void main(String[] args) { 5 int[] num = {1,2,3,4,5}; //定义数组 6 7 //for (声明语句:表达式){ 8 // 代码语句 9 // } 10 for (int x:num){ 11 System.out.println(x+"\t"); 12 } 13 14 char[] n1 = {1,2,3,4,5,6,7,8,9}; 15 char[] n2 = {1,2,3,4,5,6,7,8,9}; 16 17 for(int x1:n1){ //自动转换char到int,参见之前数据类型介绍。 18 for(int x2 : n2){ 19 if (x1 <= x2) { 20 System.out.print(x1+"*"+x2+"="+x1*x2+"\t"); 21 } 22 } 23 System.out.println(); 24 } 25 } 26 }
                    
                
                
            
        
浙公网安备 33010602011771号