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.

28th Aug 2020, 6:57 PM
Jordan
Jordan - avatar
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
30th Aug 2020, 5:37 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 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.
28th Aug 2020, 8:36 PM
Avinesh
Avinesh - avatar
30th Aug 2020, 5:16 PM
Avinesh
Avinesh - avatar
+ 1
It is because the Animal and Main java files are in different folder, place them in the same folder location.. and then recompile
30th Aug 2020, 5:29 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
+ 1
Actually I found the com.company and did what you said and it worked!!! Thank you so much!!!
30th Aug 2020, 5:45 PM
Jordan
Jordan - avatar
0
Animal dog = new Animal(); You missed this "()" at the end which is a call to the default constructor of the class Animal.
28th Aug 2020, 7:16 PM
Avinesh
Avinesh - avatar
0
Little did Intellij new 😅😅
28th Aug 2020, 7:28 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
0
Avinesh I tried that and it still says, "Cannot resolve symbol 'Animal'.
28th Aug 2020, 7:39 PM
Jordan
Jordan - avatar
0
Avinesh, How do I make a post in my feed?
29th Aug 2020, 5:59 PM
Jordan
Jordan - avatar
0
Avinesh How do I place them in the same folder location?
30th Aug 2020, 5:31 PM
Jordan
Jordan - avatar
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'.
30th Aug 2020, 5:33 PM
Avinesh
Avinesh - avatar
0
What's the company?
30th Aug 2020, 5:34 PM
Jordan
Jordan - avatar
0
The folder you have in your project structure under which you have created the Main class.
30th Aug 2020, 5:35 PM
Avinesh
Avinesh - avatar
0
I'm still not sure where the com.company is.
30th Aug 2020, 5:39 PM
Jordan
Jordan - avatar
0
In Intellij do yo have left sidebar where folder structure is visible?
30th Aug 2020, 5:41 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar
0
Yes, so do I click on the Main.java file name and where do I place the file?
30th Aug 2020, 5:43 PM
Jordan
Jordan - avatar
0
No please!! Just share the screenshot of the left sidebar, or take a proper screenshot from your system, and then share it here
30th Aug 2020, 5:44 PM
Мг. Кнап🌠
Мг. Кнап🌠 - avatar