정수를 Integer 개체로 변환하는 convert2ObjAndStore 함수가 포함 된 WrapperDemo 클래스를 만들고이 Integer 개체를 intVector.Store "n "intVector.Iterate 벡터와 정수 값으로 객체를 받고 그것을 표시합니다. 또한 하나의 Integer 객체를 다른 객체와 교환하고 호출 된 루틴에 교환 된 값을 표시하는 함수를 포함합니다 (주 함수는 WrapperMain)래퍼 클래스 (프리미티브 배열을 래퍼 배열로 변환하는 방법
나는이 시도했지만 정수 개체를 interger 변환 오류가 발생했습니다
import java.util.*;
class WrapperDemo {
static void Convert(Integer []ob,int n) {
Vector<Integer> store=new Vector<Integer>();
for(int i=0;i<n;i++) {
store.add(ob[i]);
System.out.println(store.get(i));
}
}
}
class WrapperMain {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
sc.nextLine();
int[] x=new int [20];
for(int i=0;i<n;i++) {
x[i]=sc.nextInt();
WrapperDemo.Convert(x,n);
}
}
}
서식을 수정하십시오. –
* 오류가 발생합니다 * : 오류 메시지를 읽고 무엇이 잘못되었는지 그리고 어디에 있는지 확인합니다. –