java 零基础 第十一天 Eclipse使用,数组操作

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);
	}
	/*
	 * a. 找出数组中最大值的下标位置
	 * 方法分析:
	 * 		固定格式:
	 * 			public static 不要问
	 * 		返回值类型:
	 * 			int 返回值数据是类型
	 * 		方法名:
	 * 			maxIndexOf 最大值下标位置
	 * 		形式参数列表:
	 * 			int[] arr 这里需要在一个int类型数组中找出
	 * 
	 * 方法声明:
	 * 		public static int maxIndexOf(int[] arr)
	 */
	
	/**
	 * 找出数组中最大值的下标位置
	 * 
	 * @param arr 查询最大值下标位置的数组
	 * @return 返回最大值所在的下标位置,int类型
	 */
	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);
	}
	
	/*
	 * b. 找出数组中最小值的下标位置
	 * 方法分析:
	 * 		固定格式:
	 * 			public static
	 * 		返回值类型:
	 * 			int 
	 * 		方法名:
	 * 			minIndexOf
	 * 		形式参数列表:
	 * 			(int[] arr)
	 * 方法声明:
	 * 		public static int minIndexOf(int[] array)
	 */
	
	/**
	 * 找出数组中最小值下标位置
	 * 
	 * @param array 查询操作的数组
	 * @return 最小值的下标位置
	 */
	public static int minIndexOf(int[] array) {
   
		int minIndex = 0;
		
		for 
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值