Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

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

Đang mở Phù hợp với người mới
#35 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@tanujb03 đang làm issue này rồi.

Từ ngày 10/10/2026.

  • #36 của @tanujb03 — đang mở

Đánh giá

Độ khó
1/5
Thời gian dự kiến
Dưới một giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
java, python
Lĩnh vực
tooling

Hướng nghiên cứu

Bản sửa nằm trong problems/prime/solution.java: đổi tên lớp public PrimeCheck thành Solution và làm cho isPrime thành static, nên tệp cũng phải đổi tên thành Solution.java. Hãy so sánh với problems/binary-search/Solution.java, mà mục Layout trong README nêu làm quy ước. Bắt đầu bằng cách chạy python3 run.py prime --lang java để tái hiện các lỗi biên dịch. Công việc hoàn tất khi kiểm tra số nguyên tố đạt và lời giải Java in ra prime hoặc not prime.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
Python
Star
1
Fork
6
Merge trung bình
17 giờ 52 phút
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của techcsispit/code-corner

Tất cả issue của techcsispit/code-corner

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.