Skip to content
How to access one class from another class that's in the same project
Profile icon
NimishP

I want to make a project that consists of different games in different classes. How would I do this?

Here is the link to my repl
https://repl.it/@NimishP/Games

I want to be able to go from one class to another when I run the code.

Thanks,
NimishP

You are viewing a single comment. View All
Profile icon
TheDrone7

If the file with the class is in the same directory as your main file then you can simply do import ClassName; in your main.java file to start using it.

Profile icon
NimishP

@TheDrone7
Oh ok thanks!

Profile icon
NimishP

@TheDrone7
But it still doesn't work

Profile icon
TheDrone7

@NimishP
I see in your repl, you named all classes Main, that might be what's causing problem, also you import using class name not file name, and I don't see any imports in your main Java file in the repl.

Profile icon
ShivamArora1

@NimishP

It doesn't work