I am having a problem regarding the printing of a special array:
I print an array of several objects with the System.out.println(Arrays.toString());
but now the array is filled with objects, that possess a value as char and I want to print each char assigned to the object.
How can I do that in code?
To clarify, let the array be something specific like this:
Class[] objList = {new Class(1, 'X'), new Class(4, 'Y')};
Where I want to call the objList[0].toString()
and then the objList[1].toString()
method, getting an output looking like:
[X, Y]
I hope this question is clear enough and would be happy if anyone could help me, thanks!
NOTE: the mentioned Class with the toString() method is just implemented in the Class and is written as System.out.print(destination);
I tried the explanation here: Use toString on array of objects, but apparently it did not work.
public String toString() {
System.out.print(Arrays.toString(objList.toString()));
return null;
}