Home > Back-end >  Consult! Java, thank you!!!!!!
Consult! Java, thank you!!!!!!

Time:09-27

Thank you very much!!!!!!!!!! I wrote that could go wrong, pursuing big brand!

CodePudding user response:

Package check;

Public class MaxMin {

Public static void main (String [] args) {
Int [] array=new int [5].
for (int i=0; i Array [I]=(int) (100 * Math. The random ());
}
For (int value: array) {
System.out.println(value);
}
System. The out. Println (" Max "+ MaxMin. GetResult (array). GetMax ());
System. The out. Println (" Min "+ MaxMin. GetResult (array). GetMin ());
For (int value: array) {
System.out.println(value);
}
}

The static Result getResult (int [] array) {
Int Max=array [0];
Int min=array [0].
For (int I: array) {
If (I & gt; Max) {
Max=I;
}
If (I & lt; Min) {
Min=I;
}
}
Return the new Result (Max and min);
}

Static class Result {
Int Max;
Int min;

Public Result (int Max, int min) {
This. Max=Max;
This. Min=min;
}

Public int getMax () {
return max;
}

Public int getMin () {
Return min;
}

}
}

CodePudding user response:

Thank you very much!!!!!!!!!!!!!!!
  • Related