Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

cannot find symbol error when using a class defined in a separate file

+1 vote
asked May 9, 2021 by Nagaraju Somaroutu (130 points)
Hi,

Can someone help how I can use java classes defined in their own files in onlinegdb? Only way I can make it working is define all of them in the same Main.Java file. This is not convenient. Any help is appreciated.

Thanks

Naga

2 Answers

0 votes
answered May 15, 2021 by dinesh chauhan (140 points)
No the program will execute in main method but you can create other class   and create an obect  in main class  for calling methods and function in main class.

for example

class Dog{

}

class Main

{

public static void main(String[] args)

{
Dog dog=new Dog();

}

}

through this you differ your different program
0 votes
answered May 17, 2021 by Peter Minarik (86,240 points)

Left to the RUN button there are two smaller buttons: New File and Upload File.

You can use these to add new files to your project.

Now, you'll be able to separate your classes into their own files.

Good luck!

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...