I have made a new project named “Barbie”. And I created a class named “HiBarbie”. Then I typed “System.out.print(“Hey”);” and clicked on run. But an error is showing. And the error is “Must declare a named package because this compilation unit is associated to the named module”. I unable to understand this. Kindly solve my doubt and give a solution to this problem.
Must declare a named package because this compilation unit is associated to the named module
kindly resolve my doubt
@saijaltripathy_e79096f8f1ec20e3 Extremely sorry for the late reply. Saijal when you create a project you have to create a package in the src folder and then you can create classes by any name you want.
Also you cannot directly create a class in project. Goto src inside project then create package and then create the class and you will not get any error.
do I need to create package for every new project?
And for some class names like First, Second, etc., it is not showing any error. Why?
And in YouTube, in many videos, they are telling to delete module.info under the project name., and then no error will show. Shall I do that?
@saijaltripathy_e79096f8f1ec20e3 you can try deleting modulo.info but it can give you some errors.
you an create multiple packages within a single project.
Ok thank you so much Sir.