Define a Java class to solve this problem:
Given a String and a Character, remove all instances of the Character in the String
Solve this two ways:
- Iterate through the String, one character at a time
- Find a method in the String class that can solve this in one line
Write methods for each solution. Written Java class should have a main method, allowing to execute it without parameters (default execution) and with parameters. This class should allow accepting as parameters original string and a character to be removed.
Afterwards, write a TestNG or JUnit class for each solution which tests these methods.
Include both positive and negative cases for validations.
All tests may be combined in a one or several test cases.
Positive tests should include at least two words as original string.
Negative tests should include at least the case when removable character is not part of original string, string with spaces only, empty string, null string.
Provide a screenshot showcasing results of executing JUnit tests for both methods.