我没看懂代码。谁能解释一下将Integer.Max_Value

【问题描述】:

import java.io.*;
import java.util.Arrays;
class Test
{
static private void getElements(int[] arr, int n)
{
if (n == 0 || n==1)

图片[1]-我没看懂代码。谁能解释一下将Integer.Max_Value-唐朝资源网

{ System.out.print(-1); System.out.print(" "); System.out.print(-1); System.out.print("n"); } int small = Integer.MAX_VALUE; int second_small = Integer.MAX_VALUE; int large = Integer.MIN_VALUE; int second_large = Integer.MIN_VALUE; int i; for (i = 0;i for (i = 0;i < n;i++) { if (arr[i] second_large && arr[i] != large) {

图片[2]-我没看懂代码。谁能解释一下将Integer.Max_Value-唐朝资源网

second_large = arr[i]; } } System.out.println("Second smallest is "+second_small); System.out.println("Second largest is "+second_large); } public static void main(String[] args) { int[] arr = {1, 2, 4, 6, 7, 5}; int n = arr.length; getElements(arr, n); } }

我看不懂代码。谁能解释一下将 Integer.Max_Value 分配给小值,将 integer.min_value 分配给大数的逻辑,并解释一下 integer.max_value 和 min_value 的使用以及何时使用它们。

【讨论】:

© 版权声明
THE END
喜欢就支持一下吧
点赞183赞赏 分享
评论 抢沙发
头像
欢迎您留下宝贵的见解!
提交
头像

昵称

取消
昵称表情代码图片

    暂无评论内容