Understanding of arrays are very important for any programmer and to develop this understanding there are lots of programming exercise beginners can do. One of them is
write a program to find smallest and largest number in an integer array. Java programmers are no different than others, so they can do this program in Java, not just to understand array but also relational operators available in Java. In this program, you need to write a method, yes we call function a method in Java, which will accept an
integer array and then print largest and smallest number from that array. Use of any third-party library or API method is not allowed, which means you need to do this exercise by using basic tools of Java programming language, which includes operators, control statements, keyword and some classes from
java.lang package. This problem is also known as
finding maximum and minimum numbers in a array, and technique mentioned here can be used in any other programming language as well. As a bonus point, you can also write
JUnit test cases to test your method, I have not done so and relied on simple main method to test my code to show the output and keep it short, essential for any example or demo.