0
This java program is intended to print even indexed then odd indexed char of string after a space
https://code.sololearn.com/cH91oGk7fPX0/?ref=app Plz help me debug the code. https://code.sololearn.com/cH91oGk7fPX0/?ref=app
3 odpowiedzi
+ 1
- you want to use two arrays, declare them before the loop for ()
.the length can be half of the original length
- it is not necessary to test whether it is an even / odd index, it is given by the order even, odd, even...
- in the for () loop, use two counters, one (i) for the original string and the other (ii) for indexing the result
- then in one step of the cycle,
add element to the even and
add next element to the odd array
thus (i) rises by two and (ii) by one
- print result after for ()
+ 3
Actually your code have stray errors this error coming when you copying code from any website in your code there are small dots in each line at the end of statement whicb are hidden if you will paste in vs code may be it will be visible to you . To remove this error write code self
+ 2
Did you copied this code from a other program, because the char code saves the spaces differently.
You need to delete the spaces and add them again.