Home > DeveloperSection > Forums > How to print array without using loop and recursion In java
lois waisbrooker
lois waisbrooker

Total Post:70

Posted on    December-04-2015 11:32 PM

 Java Java  Array 

 1 Reply(s)
 1032  View(s)
Rate this:
In my application there is need to print values of array. I can not use any loop or recursion and want to print all values from http response. There is any way to print java array without using loop or recursion. For Example I have array int [] ={102,202,..12}. now i want to print values as

102,202 .. 12 . Order maintain is not necessary .

Mayank Tripathi
Mayank Tripathi

Total Post:397

Posted on    December-04-2015 11:35 PM

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);    

Don't want to miss updates? Please click the below button!

Follow MindStick