Java 返回数组方法的奇怪输出

Java 返回数组方法的奇怪输出,java,arrays,output,Java,Arrays,Output,以下是工作执行代码的“主要”主体: public class ArrayFunHouse { //instance variables and constructors could be used, but are not really needed //getSum() will return the sum of the numbers from start to stop, not including stop public static int getSum(i

以下是工作执行代码的“主要”主体:

public class ArrayFunHouse
{
    //instance variables and constructors could be used, but are not really needed

    //getSum() will return the sum of the numbers from start to stop, not including stop
    public static int getSum(int[] numArray, int start, int stop)
    {
        int sum = 0;

        for(int count = start; count <= stop; count++) {
            sum += numArray[count];
        }
        return sum;
    }

    //getCount() will return number of times val is present
    public static int getCount(int[] numArray, int val)
    {
        int present = 0;

        for(int count = 0; count < numArray.length; count++) {
            if(numArray[count] == val) {
                present++;
            }
        }
        return present;
    }

    public static int[] removeVal(int[] numArray, int val)
    {
        int[] removal = new int[numArray.length - getCount(numArray, val)];
        int arbitrary = 0;

        for(int count = 0; count < removal.length; count++) {
            if(numArray[count] == val) {
                arbitrary++;
            } else {
                removal[count - arbitrary] = numArray[count];
            }
        }

        return removal;
    }
}

返回我在尝试打印没有toString的类时所期望的内容,即:

[4, 10, 0, 1, 7, 6, 5, 3, 2, 9]
sum of spots 3-6  =  19
sum of spots 2-9  =  33
number of 4s  =  1
number of 9s  =  1
number of 7s  =  1
new array with all 7s removed = [I@56f7ce53
我知道我在《跑步者》中对它的称呼是正确的,没有太多问题,不能指出问题所在,有什么建议吗

最终编辑:那太尴尬了。问题实际上是在运行程序中,没有调用Arrays.toString

打印

System.out.println(Arrays.toString(array));
如果你的数组里面有数组

System.out.println(Arrays.deepToString(array));
打印

System.out.println(Arrays.toString(array));
如果你的数组里面有数组

System.out.println(Arrays.deepToString(array));

如前所述,您正在打印返回数组的
toString()
。但是,在Java中,数组不会覆盖
toString()
,因此您将获得输出。
使用
Arrays.toString(int[])
打印返回的值,而不仅仅是打印返回的值。这将为您提供所需的输出。

如您所述,您正在打印返回数组的
toString()
。但是,在Java中,数组不会覆盖
toString()
,因此您将获得输出。
使用
Arrays.toString(int[])
来打印它的值,而不是仅仅打印返回值。这将为您提供所需的输出。

您如何打印该值?向我们显示您调用该方法并使用其返回值的代码。您可能认为您没有搞错这一部分,但所有证据都表明您确实搞错了。使用
数组。toString(数组)
“返回我在尝试打印没有toString的类时所期望的内容,即:[I@56f7ce53"-完全正确。数组不会覆盖
toString
。您如何打印该值?向我们显示您调用该方法的代码以及使用其返回值的代码。您可能认为您没有搞错该部分,但所有证据都表明您确实做了。请使用
Arrays.toString(array)
“返回我在尝试打印没有toString的类时所期望的内容,即:[I@56f7ce53“-完全正确。数组不会覆盖
toString