File tree 2 files changed +8
-8
lines changed
2 files changed +8
-8
lines changed Original file line number Diff line number Diff line change 10
10
public class RemoveDuplicateFromString {
11
11
public static void main (String [] args ) throws Exception {
12
12
BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
13
- String inp_str = br .readLine ();
13
+ String inpStr = br .readLine ();
14
14
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 ));
17
17
18
18
br .close ();
19
19
}
@@ -32,7 +32,7 @@ public static String removeDuplicate(String s) {
32
32
return s ;
33
33
}
34
34
35
- StringBuilder sb = new StringBuilder ("" );
35
+ StringBuilder sb = new StringBuilder ();
36
36
int n = s .length ();
37
37
38
38
for (int i = 0 ; i < n ; i ++) {
Original file line number Diff line number Diff line change 9
9
*
10
10
* @author Unknown
11
11
*/
12
- class ReverseString {
12
+ public class ReverseString {
13
13
14
14
/**
15
15
* This method reverses the string str and returns it
@@ -18,9 +18,9 @@ class ReverseString {
18
18
* @return Reversed string
19
19
*/
20
20
public static String reverse (String str ) {
21
- if (str . isEmpty () || str == null ) return str ;
21
+ if (str == null || str . isEmpty () ) return str ;
22
22
23
- char arr [] = str .toCharArray ();
23
+ char [] arr = str .toCharArray ();
24
24
for (int i = 0 , j = str .length () - 1 ; i < j ; i ++, j --) {
25
25
char temp = arr [i ];
26
26
arr [i ] = arr [j ];
@@ -35,7 +35,7 @@ public static String reverse(String str) {
35
35
* @param args Command line arguments
36
36
* @throws IOException Exception thrown because of BufferedReader
37
37
*/
38
- public static void main (String args [] ) throws IOException {
38
+ public static void main (String [] args ) throws IOException {
39
39
BufferedReader br = new BufferedReader (new InputStreamReader (System .in ));
40
40
System .out .println ("Enter the string" );
41
41
String srr = br .readLine ();
You can’t perform that action at this time.
0 commit comments