79691676

Date: 2025-07-06 10:50:56
Score: 1
Natty:
Report link

Error : No class declared in source file

The error is mainly due to wrong class declared. To solve there are two methods

  1. check for class name and file name

    if your file name is basics.java then class name must be basics and written like this public class basics{

    and for best compilation there must be not space between basics and { this brakcet

  2. check for correct compilation in terminal

    it must be javac basics.java (maybe you only used javac basics)

    and after the compilation task to run the file use java basics.java (maybe you forgot to type .java)

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Low reputation (1):
Posted by: Harsh Vij