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

Get the minimum value in an array in 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 :: java regex 
Java :: java get relative path 
Java :: No Java files found that extend CordovaActivity. [ERROR] An error occurred while running subprocess cordova. 
Java :: scanner.hasnext() 
Java :: default argument in java 
Java :: runtime intalize array in java 
Java :: java hash password 
Java :: how to find the size of a queue in java 
Java :: matrice java 
Java :: java declare a list 
Java :: java not equals string 
Java :: can interface have attributes java 
Java :: how to use sql file in java 
Java :: current time in long java 
Java :: java how to define a function 
Java :: how to change the value of an arraylist in java 
Java :: dot operator java 
Java :: how to find selenium webelement java 
Java :: multiplication program java 
Java :: importing all java libraries 
Java :: calculate time java 
Java :: Finding the Sum of an Array in Java 
Java :: add character to a string java 
Java :: get string from int java 
Java :: watch service java 
Java :: how junit test getter and setter 
Java :: how to add the last area of an array in java 
Java :: This version of the Android Support plugin for IntelliJ IDEA (or Android Studio) cannot open this project, please retry with version 4.2 or newer. 
Java :: How to check if a string is in alphabetical order in java 
Java :: com.android.okhttp.internal.http.HttpURLConnectionImpl cannot be cast to javax.net.ssl.HttpsURLConnection 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =