Can you help me how to remove the space in my array | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Can you help me how to remove the space in my array

This is the output of my code: [2, 5]-[4]-[3, 1] And the expected output ; [2,5]-[4]-[3,1] Just need help to remove the space https://code.sololearn.com/cN4FLANp8uo3/?ref=app

7th Dec 2021, 11:05 AM
Ecyojer
Ecyojer - avatar
3 Answers
+ 4
Ecyojer What about to use replace method like this: (startArray).replace(" ", "") or store result in a variable name result and do like this: System.out.println (result.replace(" ", ""));
7th Dec 2021, 4:54 PM
A͢J
A͢J - avatar
+ 2
7th Dec 2021, 11:16 PM
Ecyojer
Ecyojer - avatar
+ 1
Isn't that a part of output formatting / styling used by Arrays.toString(), including the use of square brackets?
7th Dec 2021, 12:51 PM
Ipang