for5.java
来自「java 的好东西,,开发的基本语言语法教程」· Java 代码 · 共 36 行
JAVA
36 行
/**
* 数组循环
*/
public class For5{
public static void main(String[] args){
arrayLoopRefactoring_1();
System.out.println("-----------");
arrayLoopRefactoring_2();
System.out.println("-----------");
}
//
public static void arrayLoopRefactoring_1(){
int[] myArray = {1 , 2 , 3 , 4} ;
for(int x = 0;x<myArray.length;x++) {
System.out.println(myArray[x]);
}
}
//1.5
public static void arrayLoopRefactoring_2(){
int[] myArray = {1,2,3,4};
for(int item:myArray) {
System.out.println(item);
}
String[] lst={"你好","ok","hello"};
for(String s:lst){
System.out.println (s);
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?