Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- public class swapALL
- {
- public static void main(String [] args)
- {
- int[] mudkip = {12, 34, 56};
- int[] marshstomp = {20, 50, 80};
- swapALL(mudkip, marshstomp);
- System.out.println(Arrays.toString(mudkip));
- System.out.println(Arrays.toString(marshstomp));
- }
- public static void swapALL(int[] mudkip, int[] marshstomp)
- {
- int[] temp = new int[mudkip.length];
- for(int i = 0; i < temp.length; i++)
- {
- temp[i] = mudkip[i];
- }
- for(int i = 0; i < temp.length; i++)
- {
- mudkip[i] = marshstomp[i];
- }
- for(int i = 0; i < temp.length; i++)
- {
- marshstomp[i] = temp[i];
- }
- }
- }
- import java.util.*;
- public class Merge
- {
- public static void main(String [] args)
- {
- int[] a1 ={12, 34, 56};
- int[] a2= {7, 8, 9, 10};
- int[] a3 = merge(a1, a2);
- System.out.println(Arrays.toString(a3));
- }
- public static int[] merge(int[] a1, int[] a2)
- {
- int[] a3 = new int[a1.length + a2.length];
- int count = 0;
- for(int i = 0; i < a1.length; i++)
- {
- a3[i] = a1[i];
- count++;
- }
- for(int x = 0; x < a2.length; x++)
- {
- a3[count] = a2[x];
- count++;
- }
- return a3;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment