find min in array java
Java
import java.util.Random;
public class Main {
public static void main(String[] args) {
int a[] = new int [100];
Random rnd = new Random ();
for (int i = 0; i< a.length; i++) {
a[i] = rnd.nextInt(99-0)+0;
System.out.println(a[i]);
}
int max = 0;
for (int i = 0; i < a.length; i++) {
a[i] = max;
for (int j = i+1; j<a.length; j++) {
if (a[j] > max) {
max = a[j];
}
}
}
System.out.println("Max element: " + max);
}
}public static double arrayMax(double[] arr) {
double max = Double.NEGATIVE_INFINITY;
for(double cur: arr)
max = Math.max(max, cur);
return max;
}import java.util.Arrays;
public class apples {
public static void main(String[] args) {
int a[] = {2,5,3,7,8};
Arrays.sort(a);
int min =a[0];
System.out.println(min);
int max= a[a.length-1];
System.out.println(max);
}
}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;
}
Also in Java:
- Title
- java insertion sort
- Category
- Java
- Title
- java repository sql find not in list
- Category
- Java
- Title
- socket in java
- Category
- Java
- Title
- java pass arraylist by value
- Category
- Java
- Title
- java random number in range
- Category
- Java
- Title
- java random integer
- Category
- Java
- Title
- reverse array in java
- Category
- Java
- Title
- java vs javascript
- Category
- Java
- Title
- java letter alphabet index
- Category
- Java
- Title
- send variable intent
- Category
- Java
- Title
- how to get the dimensions of a 2d array in java
- Category
- Java
- Title
- how to calculate exponential in java
- Category
- Java
- Title
- using class in java
- Category
- Java
- Title
- java output length of each line in a text document
- Category
- Java
- Title
- check if list contains new line in java
- Category
- Java
- Title
- input java
- Category
- Java
- Title
- kotlin android intent pass data
- Category
- Java
- Title
- how to get a user input in java
- Category
- Java
- Title
- sieve in java
- Category
- Java
- Title
- java how to convert string to int
- Category
- Java
- Title
- same method name with different arguments
- Category
- Java
- Title
- java how to call getReader twice
- Category
- Java
- Title
- get day name from date in java
- Category
- Java
- Title
- how to remove all components from layeredPane java
- Category
- Java
- Title
- java read file text
- Category
- Java
- Title
- install java debian 8
- Category
- Java
- Title
- priority queue java reverse order
- Category
- Java
- Title
- java list all non directory files in the directory
- Category
- Java
- Title
- java random char a-z
- Category
- Java
- Title
- how to exit a java program
- Category
- Java
- Title
- rewrite file java
- Category
- Java
- Title
- convert array of int to arraylist java
- Category
- Java
- Title
- java next permutation
- Category
- Java
- Title
- primitive and non primitive data types in java
- Category
- Java
- Title
- parallel sorting in java 8
- Category
- Java
- Title
- java read string input
- Category
- Java
- Title
- nikita kaksharov
- Category
- Java
- Title
- 2d arrays | java
- Category
- Java
- Title
- raise number to power java
- Category
- Java
- Title
- java previous permutation
- Category
- Java
- Title
- java split string
- Category
- Java
- Title
- java lambda list of objects cast
- Category
- Java
- Title
- sort array java
- Category
- Java
- Title
- que es un length en java
- Category
- Java
- Title
- java get annotation value
- Category
- Java
- Title
- how to get the screen dimensions in java
- Category
- Java
- Title
- string remove last character
- Category
- Java
- Title
- sqrt in java
- Category
- Java
- Title
- if en une seul ligne java
- Category
- Java
- Title
- java print treemap
- Category
- Java
- Title
- java valeur absolue
- Category
- Java
- Title
- capcitor FERR_CLEARTEXT_NOT_PERMITTED
- Category
- Java
- Title
- java parse json
- Category
- Java
- Title
- java projects
- Category
- Java
- Title
- can we overload a static method in java
- Category
- Java
- Title
- how to copy list item to another list in java
- Category
- Java
- Title
- switch en java
- Category
- Java
- Title
- android hide and show bottom navigation
- Category
- Java
- Title
- convert int to string java
- Category
- Java
- Title
- html redirect
- Category
- Java
- Title
- java iterate through map
- Category
- Java
- Title
- lightweight java game library
- Category
- Java
- Title
- object orientation in java
- Category
- Java
- Title
- regex get string between quotes java
- Category
- Java
- Title
- change fab image programatically
- Category
- Java
- Title
- java switch display panel
- Category
- Java
- Title
- Java int to roman
- Category
- Java
- Title
- print out value java
- Category
- Java
- Title
- for loop java
- Category
- Java
- Title
- how to initialize an array in java
- Category
- Java
- Title
- LocalRegistry java rebind() java8
- Category
- Java
- Title
- Unrecognized option: --version Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
- Category
- Java
- Title
- Removing DOM nodes when traversing a NodeList
- Category
- Java
- Title
- method resolve file in java
- Category
- Java
- Title
- java cmd install raspbian
- Category
- Java
- Title
- round no in java
- Category
- Java
- Title
- spigot heal player
- Category
- Java
- Title
- java script print date in YYYY-MM-DD format
- Category
- Java
- Title
- filter in list by time java
- Category
- Java
- Title
- run static method java
- Category
- Java
- Title
- simple calculator program in java
- Category
- Java
- Title
- switch java 11
- Category
- Java
- Title
- declare hashmap java
- Category
- Java
- Title
- get material of block bukkit
- Category
- Java
- Title
- split method in java
- Category
- Java
- Title
- javafx polygon
- Category
- Java
- Title
- bufferedwriter doesn't write to file
- Category
- Java
- Title
- all data types in java
- Category
- Java
- Title
- in javascipt how to stop further page processing
- Category
- Java
- Title
- loop while in java
- Category
- Java
- Title
- java exceptions for catch
- Category
- Java
- Title
- html top padding
- Category
- Java
- Title
- biginteger in java
- Category
- Java
- Title
- logger in java
- Category
- Java
- Title
- java instantiate collection with values
- Category
- Java
- Title
- how to interrupt a void java
- Category
- Java
- Title
- init admob
- Category
- Java
- Title
- find the day of the week Calendar class in java
- Category
- Java
- Title
- catch array out of bounds exception java
- Category
- Java
- Title
- java 8 random string generator
- Category
- Java