Ask coding questions

← Back to all posts
how to run only specific file
sandiptikole (13)

i added new file and it has main method and i want to run only that file. currently it is running only first added file which has main method

Comments
hotnewtop
PiotrZdunski (3)

in console type in: javac BestTimeToBuyStock.java
and then java BestTimeToBuyStock

abc3354 (230)

Hi !
Replit will run the Main class and in this class the main method will be called.
If you want to have two codes, you should create two repl

There is an other way but I don't think that it is a good practice (I do not know java very well)
You can call the main method of BestTimeToBuyStock class in the Main class
This not very clear so I made an example here

Main.java line 67


Replit helper here !
If you found my answer helpful, you can upvote it :)
If my post answers the question, mark it as the answer with the check mark !

Zavexeon (1165)

Hi. Repl.it will always execute the main file first. Consider using a polygott repl.

Steven_The_GuyT (371)

What do you mean by running not main method? or maybe:

You just call the function that you want, and comment out the functions that you don't want.