Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

min of an array java

public int min()
    {
        int min = elementData[0];
        for (int i = 1; i < size; i++)
        {
            if (elementData[i] < min)
            {
                min = elementData[i];
            }
        }
        return min;
    }
Comment

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

get minimum of 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 :: how to fill a 2d array in java 
Java :: send data from service to activity class 
Java :: jdbc interface 
Java :: Java How to use Set? 
Java :: java mockito any string import 
Java :: sorting in java 
Java :: java integer division tofloat 
Java :: binary to decimal in java program 
Java :: java replace character 
Java :: java insert at index 
Java :: blurview android github 
Java :: find minimum number in java 
Java :: which api is android 12 
Java :: execute exe java 
Java :: java printf 
Java :: how to set boolean to false if null java 
Java :: how to go to next iteration of while loop java 
Java :: how to find palindrome numbers in java 
Java :: how to use arrays java 
Java :: comentario java 
Java :: Java Sorting Using sort() 
Java :: Java program to print decimal to octal conversion 
Java :: pre increment and post increments 
Java :: runnable java 
Java :: math.min java 
Java :: java get filename without extension 
Java :: class declaration in java 
Java :: quarkus maven skip test 
Java :: spring-boot java header appliacation/json constant 
Java :: hibernate in spring boot 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =