Write a Java program to convert all characters in a string to lowercase

Write a Java program to find second lowest number from the array

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);
    }
}

Result

Write a Java program to find second lowest number from the array
Write a Java program to find second lowest number from the array

Add a Comment

Your email address will not be published. Required fields are marked *