I am making a Program to find Values of Roots of a given Quadratic Equation. This is the code -
import java.util.*;
class Success
{
public static void main(String[] args)
{
String input1;
Scanner sc=new Scanner(System.in);
System.out.println();
System.out.println();
System.out.println("-------------------------------------------------------------------");
System.out.println("-------------------------------------------------------------------");
System.out.println("!! Success !!");
System.out.println("------- (-_-) -------");
System.out.println();
System.out.println("Let's Try Again!!!");
System.out.println();
System.out.println("Enter anything to Exit or 1 to go back to Main Menu.");
input1 = sc.nextLine();
if(input1.equals("1"))
{
System.out.print('\f');
Main_Menu.main(args);
}
else
{
System.exit(0);
}
}
}
Here I use System.exit(0); to exit the program. But using this just minimizes the window. Is there any way to close the window.
P.S - This is just a class which links to Main_Menu Class if the entered value is 1. This is not the full code!
Quadratic Equations - BlueJ Program - Image
Thank You
The call to
System.exit(0)
just terminates the currently running Java Virtual Machine. It doesn't necessarily close the terminal window. A Java program does not know anything about it's context, so it cannot access the window it is using for its output.However, there are two different ways to clear the terminal in BlueJ. You can get BlueJ to automatically clear the terminal before every interactive method call. To do this, activate the 'Clear screen at method call' option in the 'Options' menu of the terminal. You can also clear the terminal programmatically from within your program. Printing a formfeed character (unicode 000C) clears the BlueJ terminal, for example:
This will work in the BlueJ terminal, but is not guaranteed to have the same effect in all terminals. You could, for example, create a method with this in it and call that method whenever you want to clear the terminal screen.