Skip to content

Commit e86a97d

Browse files
authored
Fixed remove extra space at beginning and the end
Fixed remove extra space at the beginning and at the end as well
1 parent 54fe43d commit e86a97d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/main/java/com/rampatra/strings/RemoveExtraSpaces.java

+4-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,10 @@ public static String removeExtraSpaces(String s) {
4949
}
5050
}
5151

52-
return String.valueOf(Arrays.copyOf(c, j));
52+
String stringAfterRemove = String.valueOf(Arrays.copyOf(c, j));
53+
//Remove Extra Space at the beginning and the end
54+
String removeBegAndEnd = stringAfterRemove.trim();
55+
return removeBegAndEnd;
5356
}
5457

5558
public static void main(String[] args) {

0 commit comments

Comments
 (0)