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

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 :: double quotes in string java 
Java :: String remove duplicate in java 
Java :: getcurrencyinstance java example 
Java :: multiple type array java 
Java :: java install in fedora 
Java :: android add activity parent manifest 
Java :: java localdate to calendar 
Java :: string.join java 8 
Java :: how to print to the console in java 
Java :: Hourglass Java 
Java :: check key is pressed java 
Java :: priority scheduling in java 
Java :: java while loop example 
Java :: fhow to find location of java jdk 
Java :: spring boot actuator 
Java :: android toolbar menu align center 
Java :: Instant class java 
Java :: java median of list 
Java :: charat(0).touppercase() java 
Java :: android application class 
Java :: remove duplicates from sorted array 
Java :: android java listview clean 
Java :: how to check base64 in java 
Java :: java system.out.println 
Java :: java coalesce 
Java :: how to take max value from priority queue in java 
Java :: java.lang.object[4] 
Java :: final in java 
Java :: calling activity method from fragment: 
Java :: retrieving parent element from child aWebelement selenium java 
ADD CONTENT
Topic
Content
Source link
Name
1+9 =