Eclipse使用,数组操作
1. Eclipse使用
1.1 Eclipse获取
Eclipse官网
Eclipse下载页面
1.2 Eclipse安装和准备
1. 解压Eclipse压缩包到一个非中文,非C盘路径下
eclipse-jee-2020-03-R-incubation-win32-x86_64.zip
解压之后 ==> eclipse
2. eclipse文件夹中找到eclipse.exe 发送到桌面快捷方式
3. 打开Eclipse.exe
1.3 在Eclipse中创建第一个Java Project Java项目
1. File -> New -> Java Project
Alt + Shift + N Or Ctrl + N
2. 创建Java Project配置页面
3. 创建包
4. 创建Java程序
5. Ctrl + +/-
调整代码区字号
2. 作业讲解
2.1 找出数组中最大值的下标位置
package com.qfedu.a.homework;
public class HomeWork1 {
public static void main(String[] args) {
int[] array = {
1, 3, 5, 7, 9, 2, 4, 6, 8, 10};
int maxIndex = maxIndexOf(array);
System.out.println("最大值下标位置:" + maxIndex);
}
public static int maxIndexOf(int[] arr) {
int maxIndex = 0;
for (int i = 1; i < arr.length; i++) {
if (arr[maxIndex] < arr[i]) {
maxIndex = i;
}
}
return maxIndex;
}
}
2.2 找出数组中最小值的下标位置
package com.qfedu.a.homework;
public class HomeWork2 {
public static void main(String[] args) {
int[] array = {
1, 3, 5, 7, 9, 2, 4, 6, 8, 10};
int minIndex = minIndexOf(array);
System.out.println(minIndex);
}
public static int minIndexOf(int[] array) {
int minIndex = 0;
for