-1

I have a simple class named "Trida"

public class Trida {
    public double[] append(double[] pole1, double[] pole2){
        int length = pole1.length + pole2.length;
        double[] pole3 = new double[length];
        for (int i = 0; i < pole1.length; i++){
            pole3[i] = pole1[i];
            pole3[i + 1] = pole2[i];
        }
        return pole3;
    }

public static void main(String[] args) {
        Trida trida = new Trida();

        double[] pole1 = {1.0, 3.0};
        double[] pole2 = {2.0, 4.0};
        System.out.println(trida.append(pole1, pole2));
    }

When I run this code, terminal said [D@15db9742, but I want print field like that - [1.0, 2.0, 3.0, 4.0] Can you help me?

giannis christofakis
  • 8,201
  • 4
  • 54
  • 65
Kos112567
  • 67
  • 1
  • 1
  • 6

1 Answers1

0
Arrays.toString(trida.append(pole1, pole2))

Have also a look here.

In Java, arrays don't override toString(), so if you try to print one directly, you get weird output including the memory location.

kerner1000
  • 3,382
  • 1
  • 37
  • 57