posted 3 years ago
I tried it on JShell on Ubuntu Focal/bash and it worked first time. I don't think there is a problem with the code. Please give us more details about your terminal/command line.Why are you mixing an ordinary for loop and a for‑each loop?