public int min()
{
int min = elementData[0];
for (int i = 1; i < size; i++)
{
if (elementData[i] < min)
{
min = elementData[i];
}
}
return min;
}
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);
}
}
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;
}
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);
}