If you use Java version 9 or higher, you can use the Java REPL (JShell) to try pieces of code. Install it on your computer, or use an online service (e.g. replit.com).
Or, use a text editor, and create a .java file, compile it and run it: https://docs.oracle.com/javase/tutorial/getStarted/cupojava/win32.html
0
solved How to determine a java program output without any IDE?