简体   繁体   English

一起打印 int 和 int arrays

[英]print int and int arrays together

public int[] solution(int divisor, int[] arr){...}

public static void main (String[] args) {
Index method = new Index();
System.out.println(method.solution(5, 9, 7, 10,5));
    }

I want to put it together int, int[] in method.solution( ) .我想把它放在一起 int, int[] in method.solution( )

but the following error appears.但出现以下错误。

I want to make it recognized as int[] type, is there a way?我想让它被识别为int[]类型,有什么办法吗?

enter image description here在此处输入图像描述

I saw the comments and corrected them:)我看到了评论并更正了它们:)

Try:尝试:

System.out.println(Arrays.ToString(method.solution(5, new int[]{9, 7, 10, 5}))); 

You can achieve this by你可以通过

public int[] solution(int divisor, int[] arr)
{
    
    System.out.println(Arrays.toString(arr));
    return arr;
}

public static void main (String[] args) {
    Index method = new Index();
    System.out.println(method.solution(5, new int []{9, 7, 10,5}));
}

output output

[9, 7, 10, 5]
[I@15db9742

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM