提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
只要特定条件保持为真,while循环就会重复执行一条语句。
public class Main { public static void main(String[] arguments) { int[] array1 = { 1, 2, 3, 4, 5, 1, 4 }; float[] array2 = new float[array1.length]; /* n o w j a v a . c o m 提 供 */ System.out.print("array1: [ "); for (int i = 0; i < array1.length; i++) { System.out.print(array1[i] + " "); } System.out.println("]"); System.out.print("array2: [ "); int count = 0;//来自 n o w j a v a . c o m while ( count < array1.length && array1[count] != 1) { array2[count] = (