0

Can someone help me what this code mean?

It would be best if someone could explain it line by line. Thank you! -------------------------------------------------------------------------------------- package bu1.ac.kr; import java.util.Scanner; public class Minmax { public static void main(String[] args) { Scanner input = new Scanner(System.in); int[] ArrayList = new int[10]; Practice practice = new Practice(); for(int i=0; i<=ArrayList.length;i++) { ArrayList[i] = input.nextInt(); if(ArrayList[i] == -1) { break; } } practice.maxValue = practice.max(ArrayList); practice.minValue = practice.min(ArrayList); System.out.println(); System.out.println("Max Number : " + practice.maxValue); System.out.println("Min Number : " + practice.minValue); } } -------------------------------------------------------------------------------------- package bu1.ac.kr; public class Practice { int i, j = 0, minValue, maxValue; public int max(int ArrayList[]) { maxValue = ArrayList[0]; while(true) { if(maxValue <= ArrayList[i]) maxValue = ArrayList[i]; if(ArrayList[i] == -1) break; i++; } return maxValue; } public int min(int ArrayList[]) { minValue = ArrayList[0]; while(true) { if(ArrayList[j] == -1) break; if(minValue >= ArrayList[j]) minValue = ArrayList[j]; j++; } return minValue; } }

16th Jun 2022, 3:40 PM
êč€ë„ê· 
êč€ë„ê·  - avatar
2 Answers
+ 3
This code takes array items from user input and outputs its maximum and minimum values.
16th Jun 2022, 4:19 PM
JaScript
JaScript - avatar
+ 1
Minmax class first takes maximum of "10 input values, or until you enter -1". & it uses Practice class which have max method which returns maximum value of array, and min method which return minimum value of array.
16th Jun 2022, 4:26 PM
Jayakrishna 🇼🇳