An inspiring Array Program
To learn more array programshttps://wordpress-343193-1101484.cloudwaysapps.com/sum-of-boundary-elements-of-a-matrix
The maximum and minimum element of the array:-This program will print the biggest and the smallest element with its respective indexes(subscript)
To learn more array programs
A Simple program: Sum of Boundary elements of a Matrix
class maxmin{
public static void main(){
int arr[]={3,5,78,23,56,90,12,34,1,6,88,65,46,28,72,12};
System.out.println("The array is:");
int l=arr.length; for(int i=0;i<l;i++){
System.out.print(arr[i]+" ");
}
int min=arr[0];
int max=arr[l-1];
int mxp=0,mnp=0;
for(int i=0;i<l;i++){
if(arr[i]>max){
max=arr[i];
mxp=i;
}
}
for(int j=0;j<l;j++){
if(arr[j]<min){
min=arr[j];
mnp=j;
}
}
System.out.println("\nmax:"+max+" at position"+mxp);
System.out.println("min:"+min+" at position "+mnp);
}
}Output:-
The array is:
3 5 78 23 56 90 12 34 1 6 88 65 46 28 72 12
The Maximum number is:90 at position 5
The minimum number is:1 at position 8
For videos related to java programming
http://www.youtube.com/user/trushnatej
Related Posts
Continue learning with these related articles
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.
Prime Number Program in Java: Check a Number and Print Primes in a Range
Check whether a number is prime in Java by counting its factors, a faster square-root method with isPrime(), and a program that prints all prime numbers in a range.

Encapsulation, Access Specifiers and Scope of Variables in Java for ICSE Class 10
ICSE Class 10 Computer Applications notes on encapsulation: private, default, protected and public access, data hiding with getter and setter methods, instance vs static (class) variables, local variables and scope, with a solved BankAccount program.