Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1ebe496

Browse files
committed
fix bugs in ReverseString(TheAlgorithms#765)
1 parentbdb9acf commit1ebe496

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

‎Others/RemoveDuplicateFromString.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010
publicclassRemoveDuplicateFromString {
1111
publicstaticvoidmain(String[]args)throwsException {
1212
BufferedReaderbr =newBufferedReader(newInputStreamReader(System.in));
13-
Stringinp_str =br.readLine();
13+
StringinpStr =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
returns;
3333
}
3434

35-
StringBuildersb =newStringBuilder("");
35+
StringBuildersb =newStringBuilder();
3636
intn =s.length();
3737

3838
for (inti =0;i <n;i++) {

‎Others/ReverseString.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @author Unknown
1111
*/
12-
classReverseString {
12+
publicclassReverseString {
1313

1414
/**
1515
* This method reverses the string str and returns it
@@ -18,9 +18,9 @@ class ReverseString {
1818
* @return Reversed string
1919
*/
2020
publicstaticStringreverse(Stringstr) {
21-
if (str.isEmpty() ||str==null)returnstr;
21+
if (str==null ||str.isEmpty())returnstr;
2222

23-
chararr[] =str.toCharArray();
23+
char[]arr =str.toCharArray();
2424
for (inti =0,j =str.length() -1;i <j;i++,j--) {
2525
chartemp =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-
publicstaticvoidmain(Stringargs[])throwsIOException {
38+
publicstaticvoidmain(String[]args)throwsIOException {
3939
BufferedReaderbr =newBufferedReader(newInputStreamReader(System.in));
4040
System.out.println("Enter the string");
4141
Stringsrr =br.readLine();

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp