Skip to content

remove empty words#221

Open
dev-shady wants to merge 1 commit intoigorwojda:mainfrom
dev-shady:main
Open

remove empty words#221
dev-shady wants to merge 1 commit intoigorwojda:mainfrom
dev-shady:main

Conversation

@dev-shady
Copy link

Problem: if the string contained multiple whitespaces like a Tab , IndexOutOfBound Exception will come for it[0] part.
Cause: splitting with " " will create empty strings in the array. Accessing 0th index in empty string will cause the crash.
Solution: Fix it by removing empty strings before doing uppercase transformation.

for example,
input: "hello from this side"
exception : Exception in thread "main" java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

After fix: Hello From This Side

if the string contained multiple whitespaces like a Tab , IndexOutOfBound Exception will come for it[0] part. Fix it by removing empty strings.
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