在我的应用程序中,需要打印数组的值。我不能使用任何循环或递归,并且想从 http 响应中打印所有值。有任何方法可以在不使用循环或递归的情况下打印 java 数组。
例如
我有数组 int [] ={102,202,..12}。
现在我想将值打印为
102,202 .. 12 .没有必要维护订单。
最佳答案
Method 1:
We can print array without using loop or recursion as
char [] crr = {'A','B','C','D','E','F'};
System.out.println(" Print Array ="+ Arrays.toString(crr));
Output: Print Array =[A, B, C, D, E, F]
Method 2: Firstly we make arraylist from array and then print it .
String [] brr ={"HTML","PHP","JAVA","C"};
ArrayList<String> arr= new ArrayList<String>(Arrays.asList(brr));
System.out.println("ArrayList Is ="+arr);
来源:Print array without using loop/recursion
关于java - java - 如何在不使用循环和递归的情况下打印数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34101735/