每日日报7月9日

1.今天学习了数组的静,动态初始化,元素访问,内存分配

public class ArrayDemo {
public static void main(String[] args) {
int[] arr = new int[3];

//输出数组名
System.out.println(arr); //[I@880ec60

//输出数组中的元素
System.out.println(arr[0]);
System.out.println(arr[1]);
System.out.println(arr[2]);
}

数组最值

public class ArrayTest02 {
public static void main(String[] args) {
//定义数组
int[] arr = {12, 45, 98, 73, 60};
//定义一个变量,用于保存最大值
//取数组中第一个数据作为变量的初始值
int max = arr[0];
//与数组中剩余的数据逐个比对,每次比对将最大值保存到变量中
for(int x=1; x<arr.length; x++) {
if(arr[x] > max) {
max = arr[x];
}
}
//循环结束后打印变量的值
System.out.println("max:" + max);
}
}

2.遇到的问题:索引越界异常,空指针异常

3.明天打算学习“方法”:

方法的概念

方法的定义和调用

带返回值方法的定义和调用

方法重载

方法的参数传递

原文地址:https://www.cnblogs.com/wanghaoning/p/13267315.html