Is there any way to replace the first and last occurring characters in a string with another character (Java)? For example, I want to replace the first and last character of @@@
![python - Replacing characters in a word from the specified position to the end in a while loop - Stack Overflow python - Replacing characters in a word from the specified position to the end in a while loop - Stack Overflow](https://i.stack.imgur.com/AWuco.jpg)
python - Replacing characters in a word from the specified position to the end in a while loop - Stack Overflow
![Complete Kotlin Tutorial: Part 8 (Mastering Strings in Kotlin) | by Ajit Kumar Sahoo | CodeX | Medium Complete Kotlin Tutorial: Part 8 (Mastering Strings in Kotlin) | by Ajit Kumar Sahoo | CodeX | Medium](https://miro.medium.com/v2/resize:fit:1400/1*QAXReN9PLhmgTUNfPgRmiQ.png)