Hello, obviously you can see that I am new to Java and programming. I was assigned this project which is now turned in and graded. But I would like to know how to do it properly, it has to do as you might have guessed Strings, so what the question was asking was to do this
Create a class with the following 2 static methods. Also create a test class to verify that your methods are working correctly. You may use the examples below as test cases, but add a few new ones too. You will want to use the StringBuilder class for these methods.
1. Given a string, compute a new string where identical chars that are adjacent in the original string are separated from each other by a "*".
Examples are as shown below::
function name is public static String addStars(String str)
addStars("hello") → "hel*lo"
addStars("xxyy") → "x*xy*y"
addStars("aaaa") → "a*a*a*a"
2. Given a string, compute a new string where all the lowercase 'x' chars have been moved to the end of the string.
Examples are as shown below::
function name is public static String moveXs(String str)
moveXs("xxre") → "rexx"
moveXs("xxhixx") → "hixxxx"
moveXs("xhixhix") → "hihixxx"
And I had a Code that just failed straight across the board(monitor) and I was wondering how could I do this? Well I came up with this pseudo code.
Well what I knew was that any re-occurrences of a letter right after a letter would result in a putting of a "*" after the first occurrence. So I was wondering how I would do that.
The second part of it would be to take all x's from a string and put them at the end I was also wondering how to do that.
My teacher said it had to do with string buffers but I have not a clue how to use string buffers. Please if you could just help me understand how to do this.