prime/solution.java doesn't compile: public class PrimeCheck in solution.java, README requires Solution.java with a Solution class
維護者通常 1 天內回覆
評估
研究方向
修正位於 problems/prime/solution.java:將公開類別 PrimeCheck 重新命名為 Solution,並把 isPrime 設為 static,因此檔案也必須重新命名為 Solution.java。請與 problems/binary-search/Solution.java 比較,README 的 Layout 段落將其列為慣例。先執行 python3 run.py prime --lang java 重現編譯錯誤。當質數檢查通過,且 Java 解答輸出 prime 或 not prime 時即完成。
由索引模型根據 Issue 內容生成。
描述
What I did
- Fresh checkout of
main(0c95800, "Add prime solution in Java (#23)"), JDK installed. - Ran the checker for the Java solutions of the prime problem exactly as the README describes:
python3 run.py prime --lang java
What I expected
The top-level README says: "Every solution reads its input from stdin and prints the answer. Java files are named Solution.java with a Solution class." (README.md, Layout). So problems/prime/solution.java should compile and java -cp <out> Solution should print prime or not prime, like problems/binary-search/Solution.java does.
What happened instead
prime
FAIL solution.java (0.000s)
didn't compile:
problems/prime/solution.java:3: error: class PrimeCheck is public, should be declared in a file named PrimeCheck.java
public class PrimeCheck {
^
problems/prime/solution.java:31: error: non-static method isPrime(long) cannot be referenced from a static context
if (isPrime(n)) {
^
2 errors
Summary: 0 passed, 1 failed, 0 skipped
Exit code 1. The file is named solution.java (lowercase) and declares public class PrimeCheck, and main calls the instance method isPrime without an object. Because run.py always runs java -cp <out> Solution, a class with any other name could not be run even if it compiled. This also makes every python3 run.py run red: the check on main @ 0c95800 failed, while the commit before (e440a8e) passed.
Environment
code-corner main @ 0c95800, JDK 17, Windows 11 (the compile errors are the same on Linux).
I'd like to work on the fix: name the class Solution in Solution.java and make isPrime static, without changing the algorithm.
- 主要語言
- Python
- 星號
- 1
- 分支
- 6
- 平均合併
- 17 小時 52 分鐘
- 30 天內合併 PR
- 14
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 沒有貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
techcsispit/code-corner 的其他 Issue
-
Prime solution in C++ incorrectly returns true for some composite numbers可能已有人在做 @paramsj 於 1 天前認領。 未關閉
難度 1/5 1 小時以內 新手友好度 25/100
techcsispit/code-corner#38 ·
維護者通常 1 天內回覆
-
Failed compilations always report 0.000 seconds可能已有人在做 @Shivangi-singh18 於 1 天前認領。 未關閉
難度 2/5 1-3 小時 新手友好度 35/100
techcsispit/code-corner#37 · 1 則留言 ·
維護者通常 1 天內回覆
-
run.py: Python solutions are skipped on Windows when run via python instead of python3可能已有人在做 @tanujb03 於 2 天前認領。 未關閉bug good first issue
難度 1/5 1 小時以內 新手友好度 15/100
techcsispit/code-corner#29 ·
維護者通常 1 天內回覆
-
fibonacci/solution.c: prints negative numbers for n of 47 or more (F(90) prints -1581614984)可能已有人在做 @tanujb03 於 2 天前認領。 未關閉bug good first issue
難度 2/5 1-3 小時 新手友好度 25/100
techcsispit/code-corner#27 ·
維護者通常 1 天內回覆
-
binary-search/Solution.java: prints -1 when the target is the last element (`9 1 3 5 7 9`) or in a 1-element list (`5 5`)可能已有人在做 @tanujb03 於 2 天前認領。 未關閉bug good first issue
難度 2/5 1-3 小時 新手友好度 22/100
techcsispit/code-corner#26 ·
維護者通常 1 天內回覆
查看 techcsispit/code-corner 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 68/100
KalicoCrew/kalico#1012 ·
維護者通常 1 天內回覆
-
難度 1/5 1 小時以內 新手友好度 82/100
esphome/esphome.io#7657 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 62/100
VNG-Realisatie/gemma-zaken#2658 ·
-
難度 1/5 1 小時以內 新手友好度 75/100
維護者通常 1 天內回覆
-
comp/gateway comp/plugins duplicate P3 type/bug
難度 2/5 1-3 小時 新手友好度 82/100
NousResearch/hermes-agent#137019 ·
維護者通常 1 天內回覆