Ti posto il mio codice:
codice:
public class Q {
protected int v[];
public Q(int v []){
this.v=v;
}
public static Q fondiM(Q a, Q b){
int d3=a.v.length+b.v.length;
int i,j;
int c[]= new int [d3];
for(i=0;i<a.v.length;i++)
c[i]=a.v[i];
for(i=0;i<b.v.length;i++)
c[a.v.length+i]=b.v[i];
int max=0;
for(i=0;i<d3;i++){
for(j=i+1;j<d3;j++){
if(c[i]>c[j]){
max=c[i];
c[i]=c[j];
c[j]=max;
}}}
Q vett= new Q(c);
return vett;
}
public void print(){
for(int i=0;i<v.length;i++)
System.out.print(v[i]+" ");
}
public static void main(String[] args) {
// TODO Auto-generated method stub
int k1[]={1,2,4,7};
int k2[]={1,5,9};
Q vett1= new Q(k1);
Q vett2= new Q(k2);
Q res = fondiM(vett1,vett2);
res.print();
}
}
Il problema è che se utilizzo il metodo toString() ottengo come risultato questo:
vettore [I@c3c749
mentre se utilizzo il metodo print() ottengo l'output corretto: 1 1 2 4 5 7 9...per quale motivo??