Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

find minimum number in array java

public class MinimumNumber{
  public static void main(String[] args){
    int[] arr=new int[]{2,3,4,1};
    int min=arr[0];
    for(int i=0;i<arr.length;i++){
      if(arr[i]<min){
        min=arr[i];
      }
    }
    System.out.println("Minimum Number in array:"+min);
  }
}
Comment

find min in array java

private static int findMin(int[] array) {
		int min = array[0];
		for(int i=1;i<array.length;i++) {
			if(min > array[i]) {
				min = array[i];
			}
		}
		return min;
	}
Comment

minimum integer array java

int /*OR*/ double /*OR*/ float[] array_of_numbers = {/*Whatever values you want*/}
/*For this example we're just using a regular integer array*/
int min = array_of_numbers[0]; /*Important to initialise the first value!!!!*/
   for (int i = 0; i < array_of_numbers.length; i++) {
        if(array_of_numbers[i] < min) { /* So now we can make the comparison*/
            min = array_of_numbers[i];  /* If smaller, make it the new minimum*/
        }
   }
   System.out.println("Minimum value in array: " + min)
Comment

find minimum in array java

 public static void main(String[] args) {

        int[] xr = {2, 4, 1, 3, 7, 5, 6, 10, 8, 9};

        //find maximum value
        int max = xr[0];
        for (int i = 0; i < xr.length; i++) {
            if (xr[i] > max) {
                max = xr[i];
            }
        }

        //find minimum value
        int min=xr[0];
        for (int i = 0; i <xr.length ; i++) {
            if (xr[i]<min){
                min=xr[i];
            }
        }

        System.out.println("max: "+max);
        System.out.println("min: "+min);
    }
Comment

PREVIOUS NEXT
Code Example
Java :: recycler view implementation 
Java :: how do i print text in java 
Java :: how to check the lines in a file java scanner 
Java :: get day of week java 
Java :: java return list 
Java :: AmazonS3ClientBuilder 
Java :: java selenium implicitly wait 
Java :: bootstrap 4 modal get event related target 
Java :: Java Stack class pop() method 
Java :: android studio change title bar text 
Java :: Exception in thread "main" java.util.zip.ZipException: error 
Java :: Why should we mention a method throws some exception/s? 
Java :: why bufferedreader is faster than scanner 
Java :: java random number between 2 values inclusive 
Java :: try block in java 
Java :: java loop 
Java :: does set automatically get rid of duplicates in java 
Java :: max of an array java 
Java :: split string regex java 
Java :: java opts 
Java :: send whatsapp message java android studio 
Java :: java csv line split 
Java :: how to convert char to uppercase java 
Java :: pivot in array 
Java :: How to efficiently shift a linked list by k positions, in Java? 
Java :: java array loop 
Java :: fill two dimensional array rows by rows java 
Java :: Java Create ArrayList in Java 
Java :: mongodb java find all documents 
Java :: java timer 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =