Skip to content

Instantly share code, notes, and snippets.

@MkDierz
Created December 4, 2019 18:57
Show Gist options
  • Save MkDierz/5ab425b9612378dc94856d7fa0ff6a8c to your computer and use it in GitHub Desktop.
Save MkDierz/5ab425b9612378dc94856d7fa0ff6a8c to your computer and use it in GitHub Desktop.
java array declaration, find max min and total
public static void main(String[] args) {
int [] data = {3, 2, 0, 8, 10, 15, 13, 6};
int max = 0, min = 0, total = 0;
for(int i = 0; i < data.length; i++)
{
if (max < data[i]) {
max = data[i];
}
if (min > data[i]) {
min = data[i];
}
total = total + i;
}
System.out.println("max = " + max);
System.out.println("min = " + min);
System.out.println("total = " + total);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment