[Solved] Rearranging an inputted string [closed]


You can parse the input string and split it about the comma , example:-

String s1="Casey Carter, Cartwright, [email protected]";
String[] arr=s1.split(","); // you will get each individual input terms i.e first name , lastname, email in string array

Then you can build a string using it:-

String s2=arr[1]+","+arr[0];

Note that this will build string Cartwright, Casey Carter to build string Cartwright, Casey C you need to further manipulate the string consisting of firstname, which I leave for you to explore. (Hint:- you can use substring() to remove extra chars from the end of firstname).

solved Rearranging an inputted string [closed]