计算机本质程序是操作的数据,数据存在哪里?磁盘中、数据库中、程序中,最终使用肯定要到程序的内存中,在程序中哪里存放数据呢?比较常用的就是数组,比如我们存储一个班级学生的名称,成绩。。。。
数组最常用的就是访问数组的元素,比如我们想知道某位学生的信息。
一个班级有40个学生,我们想知道某一个学生的信息,怎么取?
数组中怎么取出来?第一种,通过下标、或者我们说的索引
String[] students;
students =new String[]{"张老大","李老二","王老三"};
//1、直接取出
String name1 = students[2];
//System.out.println(name1);
//2、循环遍历取出
for (int i = 0; i < students.length; i++) {
System.out.println(students[i]);
}
/**
* 〈配套视频在------今日头条--鲨鱼微课---每天分享java教程--从初级到高级〉<br>〉
* @author 鲨鱼微课
* @create 2022/2/5
* @since 1.0.0
*/
public class ShaYuWeiKe {
public static void main(String[] args) {
System.out.println("配套视频今日头条--鲨鱼微课---每天分享java教程--从初级到高级");
}
}