JAVA 面试题 写一个内部工具类

来源:百度知道 编辑:UC知道 时间:2024/07/02 02:52:16
就是写一个内部的工具类 给外面的类用。 初步实现的功能是 外部类提供的数组 要求用工具类提供 求最大值 和最小值的方法

package com.chen.model;

public class MaxMin {
private int[] shuzu;

public MaxMin(int [] a){
this.shuzu=a;
}

public int max;
public int min;

//先执行排序算法 然后调值就行了
public void paixu() {

//01.先将最大的书放到最后
int count = 0;

boolean exchange = false;

for (int j = 0; j < shuzu.length -1; j++)
{
exchange = false;

for (int i = 0;i< shuzu.length - j - 1; i++)
{

count++;

if (shuzu[i] > shuzu[i + 1])
{
//标准交换算法
int temp = 0;
temp = shuzu[i];
shuzu[i] = shuzu[i + 1];
shuzu[i + 1] = temp;

exchange = true;

}

}
if (exchange == false)
{