File tree Expand file tree Collapse file tree 2 files changed +38
-9
lines changed
Expand file tree Collapse file tree 2 files changed +38
-9
lines changed Original file line number Diff line number Diff line change 11public class CheckPalindromeString {
22
33 boolean checkPalindromeString (String input ) {
4- boolean result = true ;
5- int length = input .length ();
6- for (int i =0 ; i < length /2 ; i ++) {
7- if (input .charAt (i ) != input .charAt (length -i -1 )) {
8- result = false ;
9- break ;
10- }
11- }
12- return result ;
4+ boolean result = true ;
5+ int length = input .length ();
6+ for (int i =0 ; i < length /2 ; i ++) {
7+ if (input .charAt (i ) != input .charAt (length -i -1 )) {
8+ result = false ;
9+ break ;
10+ }
11+ }
12+ return result ;
1313}
1414
1515 public static void main (String [] args ) {
Original file line number Diff line number Diff line change 1+ public class RemoveWhiteSpaces {
2+
3+ String removeWhiteSpaces (String input ){
4+ StringBuilder output = new StringBuilder ();
5+
6+ char [] charArray = input .toCharArray ();
7+
8+ for (char c : charArray ) {
9+ if (!Character .isWhitespace (c ))
10+ output .append (c );
11+ }
12+
13+ return output .toString ();
14+ }
15+
16+ public static void main (String [] args ) {
17+
18+ RemoveWhiteSpaces removeWhiteSpaces = new RemoveWhiteSpaces ();
19+
20+ String word = "fdkjfkdj kjkjfd " ;
21+
22+ System .out .print ("remove whitespaces from `" );
23+ System .out .print (word );
24+ System .out .print ("` to no space `" );
25+ System .out .print (removeWhiteSpaces .removeWhiteSpaces ("kjkfd kjfkdj " ));
26+ System .out .println ("`" );
27+ }
28+
29+ }
You can’t perform that action at this time.
0 commit comments