Skip to content

Conversation

@ShaneDR
Copy link

@ShaneDR ShaneDR commented Oct 30, 2024

Added null support/error handling for reverseWithStringBuilder and reverseWithStringConcat functions


public static final String reverseWithStringConcat(String string) {
String output = new String();

Copy link
Author

Choose a reason for hiding this comment

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

Simple if statement that checks if the string entered into the function is null. If the string is null, then the function will return an empty string

}

public static final String reverseWithStringBuilder(String string) {
if (string == null || string.isEmpty()) { //If the string is null, return an empty string
Copy link
Author

Choose a reason for hiding this comment

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

This string uses the same if statement used in the reverseWithStringConcat function to check if the string is null, if it is return an empty string

Copy link
Author

@ShaneDR ShaneDR left a comment

Choose a reason for hiding this comment

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

Added null support for reverseWithStringConcat and reverseWithStringBuilder

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

Labels

None yet

1 participant