I konw that an array is an object in Java. I want to print one array like other objects but this won't work:
public static Object[] join(Object[] obj1,Object[] obj2)
{
Object[] sum=new Object[obj1.length+obj2.length];
int i=0;
for(;i<obj1.length;i++)
{
sum[i]=obj1[i];
}
for(int j=0;j<obj2.length;j++,i++) {
sum[i]=obj2[j];
// i++;
}
return sum;
}
public static void main(String[] args) {
// TODO code application logic here
int[] array={1,2,3,4,5};
Object[] obj1={"Nguyen Viet Q",28,"Doan Thi Ha",array};
Object[] obj2={"Nguyen Viet Q1",28,"Doan Thi Ha1"};
join(obj1,obj2);
for(Object o: join(obj1,obj2))
{
System.out.print(o.toString()+" ");// i want to print array object
}
}
Can anybody please help me?
arrayin line:Object[] obj1={"Nguyen Viet Quan",28,"Doan Thi Ha",array};?