Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fixed remove extra space at beginning and the end
Fixed remove extra space at the beginning and at the end as well
  • Loading branch information
Frankie2101 authored Feb 7, 2022
commit e86a97df48eb75b852e01ae22923ffd54d602974
5 changes: 4 additions & 1 deletion src/main/java/com/rampatra/strings/RemoveExtraSpaces.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ public static String removeExtraSpaces(String s) {
}
}

return String.valueOf(Arrays.copyOf(c, j));
String stringAfterRemove = String.valueOf(Arrays.copyOf(c, j));
//Remove Extra Space at the beginning and the end
String removeBegAndEnd = stringAfterRemove.trim();
return removeBegAndEnd;
}

public static void main(String[] args) {
Expand Down