0
IntelliJ not working for classes?
So, I am using an IDE called Intellij for my java codes. I am new to java and is currently learning about classes. I made a class in Intellij called Animal and it can bark. I then went to my main file and tried to put: Animal dog = new Animal; And what Intellij says, "Cannot resolve the symbol 'Animal". I'm not sure what I did wrong because I made a class and it seems Intellij doesn't know? So, please help.
18 Respuestas
+ 1
Jordan I think you have a package name com.company, and in that you have the Main java file
And then you created an Animal java file directly in the src folder, so first copy the Animal.java code and go to the package location com.company, and within that place that file
+ 2
Jordan could you please share the screenshot of the code. You can upload it as a post in your feed and then link it here.
+ 1
It is because the Animal and Main java files are in different folder, place them in the same folder location.. and then recompile
+ 1
Actually I found the com.company and did what you said and it worked!!! Thank you so much!!!
0
Animal dog = new Animal();
You missed this "()" at the end which is a call to the default constructor of the class Animal.
0
Little did Intellij new 😅😅
0
Avinesh I tried that and it still says, "Cannot resolve symbol 'Animal'.
0
Avinesh, How do I make a post in my feed?
0
Avinesh How do I place them in the same folder location?
0
Jordan you can just copy the Animal class and navigate to 'company' and paste it. Or else delete the Animal class and create a new one in 'company'.
0
What's the company?
0
The folder you have in your project structure under which you have created the Main class.
0
I'm still not sure where the com.company is.
0
In Intellij do yo have left sidebar where folder structure is visible?
0
Yes, so do I click on the Main.java file name and where do I place the file?
0
No please!! Just share the screenshot of the left sidebar, or take a proper screenshot from your system, and then share it here