*使用while循环遍历数组创建索引和自增索引值

package com.chongrui.test;

/*
 *使用while循环遍历数组
 *
 *
 * */

public class test {

public static void main(String[] args) {
        // TODO Auto-generated method stub
   
        String[] aves = new String[]{"白路","丹顶鹤","百灵"};//创建鸟类数组
        int index = 0;//创建索引
        System.out.println("我家花园有这种各类的鸟");
        while(index<aves.length){
            
            System.out.println(aves[index++]+" ");//自增索引值
        }
        
        
        
        
        
        
    }

}
======================

我家花园有这种各类的鸟
白路
丹顶鹤
百灵

时间: 2024-12-30 01:20:18

*使用while循环遍历数组创建索引和自增索引值的相关文章

js 使用for循环遍历数组

今天写个无聊的东西!for循环的使用!如下:定义a数组,b为伪数组! var a = [1,2,3,0,5,4]; var b = document.getElementsByTagName('li'); //[<li>1</li>,<li>2</li>,<li>3</li>,<li>4</li>,<li>5</li>] 第一种:错误型! for ( var i = 0; i <

PHP——数组中的each(),list()和while循环遍历数组

.while遍历 在while()语句每次循环中,each()语句将当前数组元素的键,赋给list()函数的第一个参数变量$key.并将当前数组元素中的值,赋给list()函数中的第二个参数变量$value,并且each()语句执行之后还会把数组内部的指针向后移动一步,因此下次while()语句循环时,将会得到该数组中下一个元素的键/值对.直到数组的结尾each()语句返回FALSE,while()语句停止循环,结束数组的遍历. <body> <?php //each()函数 取数组当前

js 实现循环遍历数组

for in循环遍历 let arr = [1, 2, 3, 4, 4, 3], str = '' for (const val in arr) { str += val + ' ' } console.log(str); // 0 1 2 3 4 5 for of循环遍历对象(数组) let arr = [1, 2, 3, 4, 4, 3], str = '' for (const val of arr) { str += val + ' ' } console.log(str); // 1

JavaScript基础 使用for循环遍历数组 并 查询 数组中是否存在指定的值

镇场诗: 清心感悟智慧语,不着世间名与利.学水处下纳百川,舍尽贡高我慢意. 学有小成返哺根,愿铸一良心博客.诚心于此写经验,愿见文者得启发.------------------------------------------ code: 1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=ut

使用for语句循环遍历数组

<?php //使用array()语句将联系人列表中第一条记录声明成一维数组$contact $contact=array(1,"高某人","A公司","北京市","(010)98765432","[email protected]"); //以表格的形式输出一维数组中的每个元素 echo "<table border='1' width='600' align='center'>

easyui 两种for 循环遍历数组

方法一: //rowArray 数组 for(var i=0;i<rowArray.length;i++){ var rowObj = rowArray[i]; } 方法二: $.each(rowArray, function(index) {var hpxxObj = rowArray[index];})

JDK5的新特性之增强for循环遍历数组或集合

[格式] 1 for(元素的类型 变量名 : 数组或Collection集合名){ 2 //此处使用变量名即可,该变量就是普通for里的i. 3 } 原文地址:https://www.cnblogs.com/schiller-hu/p/8451854.html

SCSS 使用@each 方法循环遍历数组颜色并给li赋值

$list-bg:red,orange,blue,skyblue; ul{ >li{ height: 30px; @each $c in $list-bg{ $i:index($list-bg,$c); &:nth-child(#{$i+1}){//+1是除了第一个以外的li background: nth($list-bg,$i); } } } } 原文地址:https://www.cnblogs.com/MainActivity/p/9237982.html

增强for循环遍历集合或数组

遍历:for循环遍历数组或集合:iterator迭代器遍历集合:还有增强for循环(for each)遍历数组或集合: 遍历数组: 遍历集合: 原文地址:https://www.cnblogs.com/wmqiang/p/10658532.html