File tree Expand file tree Collapse file tree 2 files changed +8
-8
lines changed
Expand file tree Collapse file tree 2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 1010public class RemoveDuplicateFromString {
1111 public static void main (String [] args ) throws Exception {
1212 BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
13- String inp_str = br .readLine ();
13+ String inpStr = br .readLine ();
1414
15- System .out .println ("Actual string is: " + inp_str );
16- System .out .println ("String after removing duplicates: " + removeDuplicate (inp_str ));
15+ System .out .println ("Actual string is: " + inpStr );
16+ System .out .println ("String after removing duplicates: " + removeDuplicate (inpStr ));
1717
1818 br .close ();
1919 }
@@ -32,7 +32,7 @@ public static String removeDuplicate(String s) {
3232 return s ;
3333 }
3434
35- StringBuilder sb = new StringBuilder ("" );
35+ StringBuilder sb = new StringBuilder ();
3636 int n = s .length ();
3737
3838 for (int i = 0 ; i < n ; i ++) {
Original file line number Diff line number Diff line change 99 *
1010 * @author Unknown
1111 */
12- class ReverseString {
12+ public class ReverseString {
1313
1414 /**
1515 * This method reverses the string str and returns it
@@ -18,9 +18,9 @@ class ReverseString {
1818 * @return Reversed string
1919 */
2020 public static String reverse (String str ) {
21- if (str . isEmpty () || str == null ) return str ;
21+ if (str == null || str . isEmpty () ) return str ;
2222
23- char arr [] = str .toCharArray ();
23+ char [] arr = str .toCharArray ();
2424 for (int i = 0 , j = str .length () - 1 ; i < j ; i ++, j --) {
2525 char temp = arr [i ];
2626 arr [i ] = arr [j ];
@@ -35,7 +35,7 @@ public static String reverse(String str) {
3535 * @param args Command line arguments
3636 * @throws IOException Exception thrown because of BufferedReader
3737 */
38- public static void main (String args [] ) throws IOException {
38+ public static void main (String [] args ) throws IOException {
3939 BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
4040 System .out .println ("Enter the string" );
4141 String srr = br .readLine ();
You can’t perform that action at this time.
0 commit comments