Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

print array in the log cat android [closed]

How can I print the arr variable in the log to see the results of the array thanks,

 public void onClick(View v) {      if(v.getId()==R.id.buttonone)      {           genrandom grandom =new genrandom();           int[] arr=new int[50];           arr = new  gen_random_number().genrandom(arr, yourXvalue);      }  } 
like image 552
user1760556 Avatar asked Nov 22 '12 12:11

user1760556


1 Answers

You can use Arrays.toString

Log.d("this is my array", "arr: " + Arrays.toString(arr)); // or System.out.println("arr: " + Arrays.toString(arr)); 

Or, if your array is multidimensional, use Arrays.deepToString()

String[][] x = new String[][] {     new String[] { "foo", "bar" },     new String[] { "bazz" } }; Log.d("this is my deep array", "deep arr: " + Arrays.deepToString(x)); // or System.out.println("deep arr: " + Arrays.deepToString(x)); // will output: [[foo, bar], [bazz]] 
like image 159
Alex Avatar answered Sep 19 '22 23:09

Alex