Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BarrejarArrays {
- public static void main(String[] args) {
- int[] arrayA = {1, 3, 5, 7, 9, 11, 13, 15};
- int[] arrayB = {2, 4, 6, 8, 10, 12, 14, 16};
- int[] nouArray = new int[arrayA.length + arrayB.length];
- //Omple la part de A.
- int indexNou = 0;
- for(int i = 0; i < arrayA.length; i++) {
- nouArray[indexNou] = arrayA[i];
- indexNou = indexNou + 2;
- }
- //Omple la part de B.
- indexNou = 1;
- for(int i = 0; i < arrayB.length; i++) {
- nouArray[indexNou] = arrayB[i];
- indexNou = indexNou + 2;
- }
- for(int i = 0; i < nouArray.length; i++) {
- System.out.println(nouArray[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement