0

Java not work

When my code is working properly the console says I have an error even though the answers are identical https://code.sololearn.com/cws7SPS3ca9I/?ref=app

26th Jan 2021, 3:19 AM
Cristofer Salazar
Cristofer Salazar - avatar
6 odpowiedzi
+ 1
Cristofer Salazar on line 9, the new char array does not have to be of a greater length than the original one. Because of that, you are printing some undesirable characters which are not visible but exist. on line 10, you are assigning `arr.length` to `tn`. The last character of the array will be at `arr.length - 1` (as index starts from 0), but you are actually assigning at `arr.length`. For the same reason, `tn` never reaches 0 and hence, the 0th index of `ft` is never assigned. Changing line 10 to `int tn = arr.length - 1` will fix the problem.
26th Jan 2021, 11:59 AM
XXX
XXX - avatar
+ 3
It's working fine. What's the problem? Can you please be more specific?
26th Jan 2021, 3:41 AM
XXX
XXX - avatar
+ 1
Your code is woRkiNg without errors check it again are you trying this code on other platform.
26th Jan 2021, 4:31 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
XXX Yes, but it's for a practice and although the result is identical Yes, but it's for a practice and although the result is identical I mischid the answer. It's module 26 of the java course
26th Jan 2021, 4:37 AM
Cristofer Salazar
Cristofer Salazar - avatar
0
Syrah Algena Try the java module 26 and it will fail even if they are identical
26th Jan 2021, 11:48 AM
Cristofer Salazar
Cristofer Salazar - avatar
0
XXX thanks :)
26th Jan 2021, 12:07 PM
Cristofer Salazar
Cristofer Salazar - avatar