上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 44 下一页
摘要: Arraylist是List接口的一个实现类,它是程序中最常见的一种集合, Arraylist内部的数据存储结构是数组形式,Arraylist是大小可变的数组, 在集合中数组叫做元素,当向集合中添加数据时,它的大小也在同时变大。 在创建集合是<E>代表集合的泛型。 泛型就是集合内的元素都是什么类型, 阅读全文
posted @ 2022-06-29 14:44 xjw12345 阅读(251) 评论(0) 推荐(0)
摘要: 使用对象类型作为方法的参数 public class Phone { String brand; //品牌 double price; //价格 String color; //颜色 //打电话 public void call(String who){ System.out.println("给" 阅读全文
posted @ 2022-06-29 11:04 xjw12345 阅读(74) 评论(0) 推荐(0)
摘要: 两个引用指向同一个对象的内存图 public class Phone { String brand; //品牌 double price; //价格 String color; //颜色 //打电话 public void call(String who){ System.out.println(" 阅读全文
posted @ 2022-06-29 10:35 xjw12345 阅读(39) 评论(0) 推荐(0)
摘要: 一个对象内存图 public class Phone { String brand; //品牌 double price; //价格 String color; //颜色 //打电话 public void call(String who){ System.out.println("给"+who+" 阅读全文
posted @ 2022-06-29 10:22 xjw12345 阅读(27) 评论(0) 推荐(0)
摘要: 手机类练习 定一个类用来模拟手机事物属性:品牌,价格,颜色行为:打电话,发短信对应到类中成员变量(属性): String brand; //品牌 double price; //价格 String color; //颜色成员方法(行为): public void call(String who){} 阅读全文
posted @ 2022-06-29 09:30 xjw12345 阅读(48) 评论(0) 推荐(0)
摘要: 数组作为方法参数 三要素: 返回值类型:只是进行打印不需要计算,所以是void 方法名称:自定义 参数列表:因为要使用方法来循环遍历传递的数组,所以参数是数组 public static void main(String[] args) { int[] arr = {1,2,3,4}; for (i 阅读全文
posted @ 2022-06-28 20:01 xjw12345 阅读(184) 评论(0) 推荐(0)
摘要: 数组中的最值 求最大值: public static void main(String[] args) { int[] arr = {45,478,15,126,441,2,31,45,21,78}; int max = arr[0]; for (int i = 0; i < arr.length; 阅读全文
posted @ 2022-06-28 17:39 xjw12345 阅读(48) 评论(0) 推荐(0)
摘要: 获取数组的长度 public static void main(String[] args) { int[] arr = new int[3]; System.out.println(arr.length); arr = new int[5]; System.out.println(arr.leng 阅读全文
posted @ 2022-06-28 16:53 xjw12345 阅读(171) 评论(0) 推荐(0)
摘要: 数组索引越界异常 数组的索引从0开始,到数组的长度-1结束,同时数组的长度-1就是数组的最后一个索引 如果访问数组的时候,指定的下标超过了数组的长度-1那么就没有下标所对应的值,那么就会引发异常。 public static void main(String[] args) { int[] arr 阅读全文
posted @ 2022-06-28 16:19 xjw12345 阅读(130) 评论(0) 推荐(0)
摘要: 两个引用指向同一个数组的内存图 public static void main(String[] args) { int[] arr = new int[3]; System.out.println(arr); System.out.println(arr[0]); System.out.print 阅读全文
posted @ 2022-06-28 16:04 xjw12345 阅读(40) 评论(0) 推荐(0)
上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 44 下一页