나는 나이에 자바를 작성하지 않은, 내 질문은 정말 간단하지만, 내 인생에 대한 오류를 알아낼 수 없다는 것을 알고.약자 같은 자바 클래스의 메서드를 호출
아래 코드를 사용하여 배열에서 가장 작은 숫자를 찾으려고합니다. 이 알고리즘은 맞다,하지만 난 마지막 인쇄 문에서 사용하려고 오류가 발생
package runtime;
import java.util.ArrayList;
public class app {
/**
* @param args the command line arguments
*/
public int findSmallElement(ArrayList<Integer> num)
{
int smElement;
smElement= num.get(0);
for(int i=0; i<num.size() ; i++)
if(num.get(i) < smElement)
smElement=num.get(i);
return smElement;
}
public static void main(String[] args) {
ArrayList<Object> num = new ArrayList<Object>();
num.add(100);
num.add(80);
num.add(40);
num.add(20);
num.add(60);
System.out.println("The size of the list is " +num.size());
System.out.println(num.findSmallElement());
}
}