Skip to content

Conversation

@OmPatel123456
Copy link

@OmPatel123456 OmPatel123456 commented Oct 30, 2024

Added null cases to string package. StringFunctions.java file needed the null cases in two methods.

public static final String reverseWithStringConcat(String string) {

// Check if the input string is null or empty, and return an empty string if true
if (string == null || string.isEmpty()) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this if block so that if the string is null or if the string is empty the program can handle these cases without crashing or outputting an unexpected output.

public static final String reverseWithStringBuilder(String string) {

// Check if the input string is null or empty, and return an empty string if true
if (string == null || string.isEmpty()) {
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added the the same if block here because this method also needs the same check as the previous regarding the null and empty string cases.

Copy link
Author

@OmPatel123456 OmPatel123456 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cases implemented

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant