package com.itheima;
public class ChangeContainer {
private Object[] oArray = new Object[1];
private int index = 0;
public void getData(Object obj) {
if(index<=oArray.length)
{
oArray[index] = obj;
}
else {
Object[] temp = new Object[oArray.length+1];
for (int i = 0; i < oArray.length; i++) {
temp[i] = oArray[i];
temp[oArray.length+1] = obj;
oArray = temp;
}
}
index++;
}
public static void main (String[] args)
{
ChangeContainer c = new ChangeContainer();
c.getData('我');
}
}
为什么c.getData('我');这句报错呢?char型的不能传给Object么?
|
|