Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

prime/solution.java doesn't compile: public class PrimeCheck in solution.java, README requires Solution.java with a Solution class

未關閉 適合新手
#35 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

@tanujb03 已經在處理了。

開始於 2026年10月10日。

  • #36 來自 @tanujb03 —— 未關閉

評估

難度
1/5
預估耗時
1 小時以內
新手友好度
82/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
java, python
領域
tooling

研究方向

修正位於 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

  1. Fresh checkout of main (0c95800, "Add prime solution in Java (#23)"), JDK installed.
  2. 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 範本
  • 沒有貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

techcsispit/code-corner 的其他 Issue

查看 techcsispit/code-corner 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。