-1

I am new to java, and I have a problem that I just have no idea how to fix. I've been searching here on stackoverflow and on other sites and I am just so confused.

I am just trying to copy my l array to a new array that's called A...

Here is my code:

public class Problem3 {

    public static void main(String args[]) {

        int l[] = new int[]{1, 2, 3};
        ArrayTools.print();

        ArrayTools.createIntArray();
        //hämta class ArrayTools och alla metoder

    }
}


class ArrayTools {

    public static void print (){
 System.out.println ("ArrayTools");
    }

    public int [] createIntArray (int l){

        int [] A = l.clone();

        System.out.println(A);
        return A;

        }
  }    

And what I get is a "int cannot be dereferenced" error when I try to compile my code.

And also I get another error with the ArrayTools.createIntArray, but I will figure that out later.

Clara
  • 1
  • 1
  • `l` is an `int`, not an array – Eran Feb 24 '20 at 14:51
  • Please change the type of the parameter l from int to int[]. – Arthurofos Feb 24 '20 at 14:53
  • You main method calling ArrayTools.createIntArray() without any parameter. And your method declaration itself createIntArray(int l) also wrong. I believed your parameter should be an array instead of int. – xiaoli Feb 24 '20 at 14:57

1 Answers1

0

Please change the type of the parameter l from int to int[].

Arthurofos
  • 158
  • 9