-2

enter image description here This is the solution I looked up but except for the array and for each loop i don't get any of that I am a total beginner by the way.

I tried to understand the problem but didn't quite get it properly, I would really like some explanation.

int[] a7={8,90,-75,863,-7845};
int min3=0;
for (int element1:a7){
  if (element1<min3){
   min3=element1;
  }
}
System.out.printIn("The Minimum Value of this array is"+min3);

Son of Man
  • 1,213
  • 2
  • 7
  • 27

1 Answers1

0

there are so many ways to get the maximum element in array.

Easy One + More Efficient

  1. assume first element is max,
  2. loop through array from 1 to n
  3. check if current element is greater than previous max or not if yes, so store it in max variable, if not keep old max value

See this the link

at the end, variable max will hold maximum element in the array

Keep in mind: Problem Solving is for your mindset, to make your brain active, and don't copy paste, or see solution after short time, take your time maybe 25min or more depending on your personality

Son of Man
  • 1,213
  • 2
  • 7
  • 27
Anonumouz
  • 62
  • 6
  • 1
    [Please never post images of text](https://meta.stackoverflow.com/questions/285551/why-should-i-not-upload-images-of-code-data-errors/285557#285557). They are not searchable, we cannot copy-paste... Always copy-paste the text and format it properly. – g00se Jun 17 '23 at 16:03