this code prints the address like this --> project.Cateogry@d038117
Cate=c.listCat();
Arrays.toString(Cate.toArray());
what is wrong ?!!!! i want to print the elements from the arraylist "Cate"
this code prints the address like this --> project.Cateogry@d038117
Cate=c.listCat();
Arrays.toString(Cate.toArray());
what is wrong ?!!!! i want to print the elements from the arraylist "Cate"
Let's check the javadoc of toArray
,
Returns an array containing all of the elements in this list in proper sequence (from first to last element).
The returned array will be "safe" in that no references to it are maintained by this list. (In other words, this method must allocate a new array even if this list is backed by an array). The caller is thus free to modify the returned array.
As you can see, the return value of it is a java array, if you want to print the content inside the array, there are multiple ways in the thread mentioned in the comment.
Btw, if you're interested about why path@hashcode is printed, please refer to this thread How do I print my Java object without getting “SomeType@2f92e0f4”?