How do i insert a random variable into a string? I created a a variable that gets me a random position in the string that i want to put a char in, but I do not know how to use that random value in order to put that char in that certain position. Here is the code I did to get the random variable-
r=0+Math.random()*intTop;
I know this gives me a double, which is why i will cast it later. intTop is the length of the string that i will put the char in. I did this substring and it does not work,-
stringTop=stringTop.substring((int)r,lastBot);
lastBot is the char variable that i want to insert at position r of the string. Please help I am truly stuck.
stringTop.substring(0, r) + lastBot + stringTop.substring(r)?