0

I'm simply trying to get my array to print correctly. This is what I have so far.

public class Driver
{
    public static void main(String[] args)
    {
        //create new instance of the ArrayLab class with parameter of 10
        ArrayClass array = new ArrayLab(10);

        array.initialize();
}

I do realize that I have a parameter for my class, the problem remains the same whether or not I have just a simple instance variable with the class parameter inside of the java array field.


public class ArrayClass
{
    //array instance variable
    private int[] array = new int[]{0,0,0,0,0,0,0,0,0,0};

    //array constructor
    public ArrayClass(int integer)
    {
        //array parameter field [0,1,2,3,4,5,6,7,8,9] 10 in total.
        int[] temp = {1,2,3,4,5,6,7,8,9,10};
        array = temp;

    }

    public void initialize()
    {

        System.out.println(array);

    }
}

It all compiles, but the problem I'm having is when it prints the output is comes up as something like this [I@1443957. What does that imply?

pewpew
  • 700
  • 2
  • 9
  • 32

1 Answers1

2

Try to print it in next way:

System.out.println(Arrays.toString(array));
Klever
  • 133
  • 8