I am Java Beginner. I made a class and a method which is to return the minimum number in the array. But I can't figure out why it is not working well.
Below is Code.
package array;
import java.util.Scanner;
class Value {
public static int minValue(int[] arr) {
for(int e : arr) {
if(arr[0] > e) {
arr[0] = e;
}
}
return arr[0];
}
}
public class ArrayTest {
public static void main(String[] args) {
int[] arr = new int[5];
System.out.print("Input Number : ");
Scanner sc = new Scanner(System.in);
for(int e : arr) {
e = sc.nextInt();
}
System.out.println("min : " + Value.minValue(arr));
}
The result is "min : 0 " What's the problem with my code???