摘要: int[] arr1 = {1, 2, 3}; int[] arr2 = {1, 2, 3}; System.out.println(compare(arr1,arr2)); } public static boolean compare(int[] arr1, int[] arr2){ if (a 阅读全文
posted @ 2022-01-13 20:14 wtws 阅读(34) 评论(0) 推荐(0)
摘要: //3、定义数组、调用方法 int[] arr = {11, 22, 33, 44, 55}; int index = seachIndex(arr,55); System.out.println("你查询的数据索引是:" + index); } //1、定义一个方法:参数接收数组,要查询的数据,返 阅读全文
posted @ 2022-01-13 20:01 wtws 阅读(144) 评论(0) 推荐(0)
摘要: public static void main(String[] args) { //打印整型数组的内容 int[] ids = {11, 22, 33, 44} ; printArray(ids); System.out.println(" "); int [] id = {}; printArr 阅读全文
posted @ 2022-01-13 19:46 wtws 阅读(75) 评论(0) 推荐(0)
摘要: Java的参数传递机制:值传递 在传输实参给方法的形参的时候,并不是传输实参变量本身,而是传输实参变量中存储的值,这就是值传递。 注意: 实参:如在方法内部定义的变量。 形参:如在定义方法时,“()”中所声明的参数。 public static void main(String[] args) { 阅读全文
posted @ 2022-01-13 19:28 wtws 阅读(57) 评论(0) 推荐(0)
摘要: 方法没有调用的时候,在方法区中的字码文件中存放 方法被调用时,需要进入到栈内存中运行 public static void main(String[] args) { study(); } public static void eat(){ System.out.println("吃饭"); } p 阅读全文
posted @ 2022-01-13 19:08 wtws 阅读(35) 评论(0) 推荐(0)
摘要: public static void main(String[] args) { //判断一个数的奇偶性 check(5); } public static void check(int number){ if (number % 2 ==0){ System.out.println(number+ 阅读全文
posted @ 2022-01-13 18:50 wtws 阅读(37) 评论(0) 推荐(0)
摘要: System.out.println("1-5的和是:"+sum(5));}public static int sum (int n){ int sum =0; for (int i =1; i <=n; i++){ sum += i; } return sum;}; 阅读全文
posted @ 2022-01-13 18:44 wtws 阅读(49) 评论(0) 推荐(0)