To run your program in IntelliJ, click the green play button next to your main method. IntelliJ compiles and executes in one step. You don't need to open a terminal or type javac and java separately.
The output appears in the Run panel at the bottom of the window. If the code has errors, IntelliJ marks the lines in red and shows the error messages in the same panel.
You can also press Shift+F10 (Windows/Linux) or Ctrl+R (macOS) to run without clicking. After your first run, IntelliJ remembers the configuration. Pressing the shortcut again reruns the same class.
If you want to run a different class, right-click its file and choose Run.