-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:nedpals/errgoengine
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
error_templates/java/test_files/public_class_filename_mismatch_error_2/ReverseString.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
String Reversal Utility | ||
Description: | ||
You're developing a feature for a text-editing app that reverses the input string from the user. This feature is crucial for certain text manipulation tasks but currently faces runtime exceptions, logic errors, and syntax issues. | ||
Task: | ||
Correct the issues causing runtime exceptions, logic errors, and syntax issues to ensure the feature can reverse a string successfully. | ||
Example Output: | ||
"dcba" | ||
*/ | ||
|
||
public class ReverzeString { | ||
public static void main(String[] args) { | ||
String str = "abcd"; | ||
String reversed = reverse(str); | ||
System.out.println(reversal); | ||
} | ||
|
||
public static String reverse(String s) { | ||
String result = ""; | ||
for(int i = s.length(); i >= 0; i--) { | ||
result += s.charAt(i); | ||
} | ||
return result; | ||
} | ||
} | ||
|
33 changes: 33 additions & 0 deletions
33
error_templates/java/test_files/public_class_filename_mismatch_error_2/test.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
name: "2" | ||
template: "Java.PublicClassFilenameMismatchError" | ||
--- | ||
ReverseString.java:14: error: class ReverzeString is public, should be declared in a file named ReverzeString.java | ||
public class ReverzeString { | ||
^ | ||
1 error | ||
=== | ||
template: "Java.PublicClassFilenameMismatchError" | ||
--- | ||
# PublicClassFilenameMismatchError | ||
This error occurs because the name of the Java file does not match the name of the public class within it. | ||
``` | ||
|
||
public class ReverzeString { | ||
^^^^^^^^^^^^^ | ||
public static void main(String[] args) { | ||
String str = "abcd"; | ||
``` | ||
## Steps to fix | ||
### 1. Rename your file | ||
Rename the file to "ReverzeString.java" to match the class. | ||
|
||
### 2. Rename the public class | ||
The filename should match the name of the public class in the file. To resolve this, change the class name to match the filename. | ||
```diff | ||
*/ | ||
|
||
- public class ReverzeString { | ||
+ public class ReverseString { | ||
public static void main(String[] args) { | ||
String str = "abcd"; | ||
``` |