Hola,
estoy haciendo un ejercicio y me funciona bien pero creando el método combina como static void. Sin embargo me piden que el método combina se cree con un public static int [] {} y no consigo saber como modificar el programa para llamar al método sin que me dé error. Os paso el programa:
public class OrdenaAscendente {
static int a1[]={10,11,20,22,50,45,87,98,65,42,15};
static int a2[]={15,16,21,23,46,85,88,78,98,99,14};
static int a[]=new int [a1.length+a2.length];
public static void combina () {
System.arraycopy(a1,0,a,0,a1.length);
System.arraycopy(a2,0,a,a1.length,a2.length);
}
public static void ordena() {
for (int i = 0; i < a.length; i++) {
for (int j = i; j > 0; j--) {
if (a[j-1] > a[j]) {
int swap = a[j];
a[j] = a[j-1];
a[j-1] = swap;
}
}
}
}
public static void muestra () {
for (int x=1;x<a.length;x++) {
System.out.print(" , "+a[x]);
}
System.out.println(" ");
}
public static void main(String[] args) {
OrdenaAscendente oa = new OrdenaAscendente();
oa.combina ();
oa.ordena();
oa.muestra();
}
}[/color]
Sabéis como tendría que hacerlo???
Desde ya, muchas gracias!!