Skip to content

Instantly share code, notes, and snippets.

@edinak1
Created October 30, 2015 18:58
Show Gist options
  • Save edinak1/308ef18a3d5019505770 to your computer and use it in GitHub Desktop.
Save edinak1/308ef18a3d5019505770 to your computer and use it in GitHub Desktop.
package masiv;
import java.util.Arrays;
public class Union {
public static void main(String[] args) {
int []data1={1,2,0,0,9};
int []data2={0,8,7};
System.out.println(Arrays.toString(union(data1,data2)));
}
static int [] union(int data1[],int data2[])
{
int [] data= new int[data1.length+data2.length];
int i=0;
for(;i<data1.length;i++)
data[i]=data1[i];
for(int k=0;k<data2.length;i++,k++)
data[i]=data2[k];
return data;
}
}
@liuiv15
Copy link

liuiv15 commented Nov 10, 2015

А если массив data1 или data2 равны null?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment