0

Arrays

How to write a method that will return the smaller value in the array? In Java.

8th Jul 2019, 4:55 PM
Beanie
Beanie - avatar
1 ответ
+ 10
might you want smallest value in array, you can use sort() method of java.util.Arrays class : import java.util.Arrays; Arrays.sort(array_name); //array_name[0] -> smallest value alternatively, you can make use of for loop(s) to find smallest element in array : int smallest=array[0]; for(int i=1;i<n;i++){ if(a>arrat_name[i]){ a=array_name[i]; } }
8th Jul 2019, 5:00 PM
Gaurav Agrawal
Gaurav Agrawal - avatar