Java的:没有打印的Arrays.toString数组 [英] Java: printing an array without Arrays.toString

查看:255
本文介绍了Java的:没有打印的Arrays.toString数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public String[] geefAlleTemplateNamen(String[][] templateLijst){
    String[] lijst = new String[templateLijst.length];
    for(int i = 0; i < templateLijst.length; i++){
        lijst[i] = templateLijst[i][0];
    }
return lijst;
}

上面的code返回数组'lijst。

The code above returns an array 'lijst'.

System.out.println(geefAlleTemplateNamen(templateLijst));

通过这块code的我试图打印数组,但它打印数组的位置。我知道这可以通过导入java.util.Arrays中得到解决,但我不允许这样做(学校项目),有没有什么办法解决?

With this piece of code I tried to print that array, but it prints the location of the array. I know this can be solved by importing Java.util.Arrays, but I am not allowed to do this (school project), is there any way to solve this?

感谢您!

推荐答案

要做到这一点,最简单和最简单的方法就是把你的数组转换成一个for循环。

The simplest and easiest way to do this is to throw your array into a for loop.

for (int i = 0; i < lijst.length; i++) { System.out.println(lijst[i]); }

打印阵列本身应该和将打印内存位置,你要访问数组中的每个成员单独来代替。

Printing the array itself should and will print its memory location, and you'll want to access each member of the array individually instead.

这篇关于Java的:没有打印的Arrays.toString数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆