Okay, then it was intentional. Then the execution is correct. But I'm not sure that your design is quite there.

Swapping the first and last elements won't make them random, it'll just make them different. What is it you're trying to do with this swap? How does it fit into your larger goal of returning a random permutation of the characters in a string?

Okay, then it was intentional. Then the execution is correct. But I'm not sure that your design is quite there.

Swapping the first and last elements won't make them random, it'll just make them different. What is it you're trying to do with this swap? How does it fit into your larger goal of returning a random permutation of the characters in a string?

hello sir,


the last element sir which is ran.nexInt(name.length()-1) is assign to integer n,
ran is instantiate of Random ran = new Random();that's why it will random the last element and swap to the first element...that's what i got sir..but if you have some suggestion to my code to make it better i will greatly appreciate,please share your idea sir..hoping for your positive responds...thank you in advance...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.