Introduction
In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..
import java.util.Arrays; public class Javaexcercise { public static void main(String[] args) { int[] myarray = {-1, 1, 2, 3, 5, 10}; System.out.println("Original numeric array : "+Arrays.toString(myarray)); int min = Integer.MAX_VALUE; int secondmin = Integer.MAX_VALUE; for (int i = 0; i < myarray.length; i++) { if(myarray[i]==min){ secondmin=min; } else if (myarray[i] < min) { secondmin = min; min = myarray[i]; } else if (myarray[i] < secondmin) { secondmin = myarray[i]; } } System.out.println("Second lowest number is : " + secondmin); } }