saving . . . saved Arrays.toString(marks) converted int value of marks to string has been deleted. Arrays.toString(marks) converted int value of marks to string has been hidden .
Arrays.toString(marks) converted int value of marks to string
Title
Question
Sir/Madam, When I am repeating the program with different values of marks and then use Arrays.toString(marks) I get different values in the output. And the braces dont convert to [ ] also.I am getting wrong output.What could be the reason. This eclipse version is the latest one eclipse java 2023. What could be the possible reason?
Regards,
Swati.










Java Array-Operations 03-04 min 10-20 sec 21-09-23, 4:58 p.m. swatisaista30@gmail.com

Answers:

System.out.println(Arrays.toString(marks).replace("{", "[").replace("}", "]"));

23-09-23, 5:53 p.m. amruthavarshinid22bcg005@skasc.ac.in
Thanks, it worked.


23-11-23, 2:16 p.m. swatisaista30@gmail.com

Login to add comment


Arrays don't override the toString() method. What you're seeing is thus the output of the default Object.toString() implementation, which contains the type of the object ([C means array of chars) followed by its hashCode.

To construct a String from a char array, use

new String(c)
27-09-23, 11:22 a.m. rajeshr21bcs143@skasc.ac.in
Sorry, I did not understand.  
23-11-23, 2:22 p.m. swatisaista30@gmail.com

Login to add comment


System.out.println(Arrays.toString(marks).replace("{", "[").replace("}", "]"));
22-11-23, 6:19 p.m. vikaashpu22bcc059@skasc.ac.in
Yes, it worked.Thanks

23-11-23, 2:22 p.m. swatisaista30@gmail.com

Login to add comment


Log-in to answer to this question.