Thanks for your annotations. First, I am generating a new String every time even in the Rust version, the purpose of this experiment is to show how can a same code in two different programming languages perform differently, and to show also how the garbage collector can cause performance overhead in some situations and how it is a good point that rust avoided garbage collection, and That's why I didn't use StringBuilder also, although I know it is more fair to compare between String of Rust and StringBuilder of Java because they both have the same Characteristics, but still gonna compare String with String because this is the purpose of the expirement, the point of char[] array is a good point, but it won't give a big difference, but thank you I will correct it. But I can assure you that the bad version of the Rust code is perfroming better than the optimized Java code (you can find it in my Java version GitHub repository in the branch "optim"). Thanks.
