Problem with ArrayList Append example

public int[] append(int[] list1, int[] list2) {
    int[] a = new int[list1.length + list2.length];
    int i = 0;
    for(int j = 0; j < list1.length; j++) {
        a[i] = list1[j];
    for(int j = 0; j < list2.length; j++) {
        a[i] = list2[j];
    return a;
public static void main(String[]args){
    Append a = new Append();
    a.append(num2, num);

Everytime I run the app it returns just fine but I see no array of integers. I just get something like this:

If anybody can tell me why this isn’t working that would be the best.

what is your class? I am unsure, can you use to duplicate the problem? I attempted it here:

but am unsure what classes you are using, and they are not in the code you included

1 Like

its the same name as the method. And I figured out what it was. I had to instantiate another array for the actual append method and set it equal to the method at hand. Then print out the array. Thanks for the reply though! :slight_smile:
I’m doing arrays for the next week though. If you guys are wondering.

int[] append=append(num2, num);

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.