0
Arrays
How to write a method that will return the smaller value in the array? In Java.
1 Resposta
+ 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];
}
}