Hi I have to write a program where I am encrypting a password. For one part of the program I have to switch half of the inputted password with the other half. So for example is my password was "Java" it would become "vaja" but I have no idea how to do this. Can someone please tell me how I would go about doing this? I think I need to create a method for it but I am not sure. Thanks in advanced.
John Sing wrote:So for example is my password was "Java" it would become "vaja"
This logic would be for password having even length. Have you thought about password having odd length. Example what if somebody sets password "Javaa" how would you apart them? Also keep in mind password should be case sensitive means "Java" and "java" are not equal. Go to link provided by Knute Snortum. Too many ready made String functions are available, utilize them and update status if you get any problem in code.
Put the String into a StringBuilder(←link) because that gives much more options for changing things. Note many of its methods return StringBuilder so you can chain method calls like this:-
So I was able to make a little program to split a string in half.
but how do I go about converting this into one string? Because if I just print one string after the other it would give the appearance that it did what it was supposed to do but in truth it actually wouldn't be. Plus there are more steps after this. So what should I do?