Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

Concatenate two arrays java

//USing Apache Commons Lang library.
int[] both = ArrayUtils.addAll(first, second);
Comment

Array concat two arrays in java

public static void main(String[] args) {

// for each ile cozumu
        String[] arr3 = {"A", "B", "C","Z","N"};
        String[] arr4 = {"D", "E", "F","G","U"};

ArrayList<String> list1 = new ArrayList<>(); //[A, B, C, Z, N, D, E, F, G, U]

        for( String each: arr3 ){
            list1.add( each );
        }
        for(String each1 : arr4  ){
            list1.add(each1);
        }
        System.out.println(list1); // [A, B, C, Z, N, D, E, F, G, U]
    }
Comment

how to merge two arrays in java

    public static void main(String[] args) {

        int[] x = {1, 2, 3};
        int[] y = {4, 5, 6};
        int[] merge = new int[x.length + y.length];

        for (int i = 0; i < x.length; i++) {
            merge[i] += x[i];
        }

        for (int i = 0; i < y.length; i++) {
            merge[x.length + i] += y[i];
        }

        System.out.println(Arrays.toString(merge));
    }
Comment

java add two arrays together

Object[] arrThree = new Object[arrTwo.length + arrOne.length];
int index = arrTwo.length;

for (int i = 0; i < arrTwo.length; i++) {
    arrThree[i] = arrTwo[i];
}
for (int i = 0; i < arrOne.length; i++) {
    arrThree[i + index] = arrOne[i];    
}
Comment

PREVIOUS NEXT
Code Example
Java :: getstring java 
Java :: how to create textview in java android 
Java :: how to get ascii value of string letter in java 
Java :: string vs new string 
Java :: java arraylist initialize with 0 
Java :: call by value and call by reference in java 
Java :: find first and last position of element in sorted array 
Java :: getter in java 
Java :: java list change element position 
Java :: encapsulation java 
Java :: arrays vs collections 
Java :: lambda expression java 
Java :: data structure java 
Java :: path in spring form 
Java :: compare 2 hashmap 
Java :: How to Initialize Arrays in Java? 
Java :: java comparator comparing 
Java :: using super in java 
Java :: private method in interface java 
Java :: sum of array in java 
Java :: java pass by reference 
Java :: kafkalistener annotation pass topic from properties file 
Java :: create fragment constructor in arrayadapter 
Java :: intellij java fx new window 
Java :: method object class in android 
Java :: intent- setaction FOR FILES 
Java :: list in list 
Java :: internal hashcode 
Java :: Declaration of java list 
Java :: how to write a perfect shuffle method in java 
ADD CONTENT
Topic
Content
Source link
Name
7+9 =